Title: Helper messages and autocomplete broken for inferred function props · Issue #22636 · microsoft/TypeScript · GitHub
Open Graph Title: Helper messages and autocomplete broken for inferred function props · Issue #22636 · microsoft/TypeScript
X Title: Helper messages and autocomplete broken for inferred function props · Issue #22636 · microsoft/TypeScript
Description: Reproduces on 2.8.0-dev.20180315 interface FooProps
Open Graph Description: Reproduces on 2.8.0-dev.20180315 interface FooProps
X Description: Reproduces on 2.8.0-dev.20180315 interface FooProps<T> { callback: (input: T) => string; value: T; } class Foo<T> extends React.Component<FooProps<T>> { public render() {...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/22636
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Helper messages and autocomplete broken for inferred function props","articleBody":"Reproduces on 2.8.0-dev.20180315\r\n\r\n```\r\ninterface FooProps\u003cT> {\r\n callback: (input: T) => string;\r\n value: T;\r\n}\r\n\r\nclass Foo\u003cT> extends React.Component\u003cFooProps\u003cT>> {\r\n public render() {\r\n return \"baz\";\r\n }\r\n}\r\n\r\nconst X = \u003cFoo callback={test => test} value=\"asd\"/>;\r\n```\r\n\r\nThe bug is visible while using an IDE like visual code, but I expect the problem is in the language server, since from what I know it's the source for helper messages and the autocomplete functionality.\r\n\r\nWhat happens is that the callback gets correctly inferred as (input: string) => string, in fact, you can write \r\n```\r\ncallback={test => test.substring(0)}\r\n```\r\nwithout errors, as the compilers actually knows that test is a string.\r\nand you cannot write \r\n```\r\ncallback={test => 42}\r\nor \r\ncallback={test => test.methodNotOnString()}\r\n```\r\n\r\nHowever, if in visual code you hover over the callback, it shows as a function T => any, instead of string => string. The return value of substring will be shown as any.\r\nMoreover autocomplete won't work correctly when trying to access a property of test.\r\nIt seems like the compiler does everything correctly in inferring the correct type, but the helper messages and autocomplete functions are instead unable to access the same inferred type.","author":{"url":"https://github.com/MastroLindus","@type":"Person","name":"MastroLindus"},"datePublished":"2018-03-16T14:43:07Z","url":"https://github.com/microsoft/TypeScript/issues/22636"}
| 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:dadc28f4-be79-d761-ab9f-96a47b7f6f92 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6D4:E9D16:299BBD:34534C:6B010074 |
| html-safe-nonce | fa2c177c78b4665d02062dffde66275394e948124e8f88a5424378511b4de9d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkQ0OkU5RDE2OjI5OUJCRDozNDUzNEM6NkIwMTAwNzQiLCJ2aXNpdG9yX2lkIjoiNzg4ODI1MTQ3MTUyMTcxMDE5NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5282b0642eb3ed198553430fd6663a82cf81493916a456fee6d410764ff8163d |
| hovercard-subject-tag | issue:305954454 |
| 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/22636/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6dcef496e6c200d874ffd6acac702860ba416e1758e7b295dd2bf3c888fa7f6e/microsoft/TypeScript/issues/22636 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6dcef496e6c200d874ffd6acac702860ba416e1758e7b295dd2bf3c888fa7f6e/microsoft/TypeScript/issues/22636 |
| og:image:alt | Reproduces on 2.8.0-dev.20180315 interface FooProps |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MastroLindus |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width