Title: Type inference not working for React ref callback param · Issue #7088 · microsoft/TypeScript · GitHub
Open Graph Title: Type inference not working for React ref callback param · Issue #7088 · microsoft/TypeScript
X Title: Type inference not working for React ref callback param · Issue #7088 · microsoft/TypeScript
Description: This looks like a type inference issue with tsc 1.8.0+ (also nightly), but I'm not sure. It could also be because of typings. The offending code looks something like this: // Inside React component render() { return
Open Graph Description: This looks like a type inference issue with tsc 1.8.0+ (also nightly), but I'm not sure. It could also be because of typings. The offending code looks something like this: // Inside React component...
X Description: This looks like a type inference issue with tsc 1.8.0+ (also nightly), but I'm not sure. It could also be because of typings. The offending code looks something like this: // Inside React compo...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/7088
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type inference not working for React ref callback param","articleBody":"This looks like a type inference issue with tsc 1.8.0+ (also nightly), but I'm not sure. It could also be because of typings.\n\nThe offending code looks something like this:\n\n``` typescript\n// Inside React component\nrender() {\n return \u003cOverlay ref={ref => this.overlayEl = ReactDOM.findDOMNode(ref) as HTMLElement} />;\n // error TS7006: Parameter 'ref' implicitly has an 'any' type.\n}\n```\n\nI'm using ref \"callback\" syntax because the string-based syntax is deprecated by react and also not type safe. Needless to say, I have \"noImplicitAny\" enabled.\n\nIt looks like ref type is now an intersection between two types (relates to https://github.com/Microsoft/TypeScript/issues/5478), and the type inference no longer works, where previously it would be an instance of `Overlay`.\n\nI can work around this issue for now by manually passing the type, like `(ref: Overlay) =>`, but it should work without it as well.\n","author":{"url":"https://github.com/use-strict","@type":"Person","name":"use-strict"},"datePublished":"2016-02-15T15:32:03Z","url":"https://github.com/microsoft/TypeScript/issues/7088"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e2973a3f-3acd-0fe5-7527-342cab382e8f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A796:E9D16:1D9E582:25872AC:6B0198FD |
| html-safe-nonce | d4b71b3a81508fee05ba8c611924786e9b3971000f0ff2c12d94b39999d8f524 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzk2OkU5RDE2OjFEOUU1ODI6MjU4NzJBQzo2QjAxOThGRCIsInZpc2l0b3JfaWQiOiI1Mjg4MzE2ODAwMTIyMDY3MTk3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c534567e03da933356ab0ef8c6db1ba13623ff059efc25b8a41a895b3e68992e |
| hovercard-subject-tag | issue:133741734 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/7088/issue_layout |
| twitter:image | https://opengraph.githubassets.com/58f6ff95cffa8c213d9faa784127e7c264f51d12b2324ad1231abe5d0e2379a6/microsoft/TypeScript/issues/7088 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/58f6ff95cffa8c213d9faa784127e7c264f51d12b2324ad1231abe5d0e2379a6/microsoft/TypeScript/issues/7088 |
| og:image:alt | This looks like a type inference issue with tsc 1.8.0+ (also nightly), but I'm not sure. It could also be because of typings. The offending code looks something like this: // Inside React component... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | use-strict |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width