Title: Instantiation expressions inconsistently trigger incorrect error messages in editor contexts · Issue #50161 · microsoft/TypeScript · GitHub
Open Graph Title: Instantiation expressions inconsistently trigger incorrect error messages in editor contexts · Issue #50161 · microsoft/TypeScript
X Title: Instantiation expressions inconsistently trigger incorrect error messages in editor contexts · Issue #50161 · microsoft/TypeScript
Description: Type: Bug Attempt to use the Instantiation Expressions in VSCode typescript language function makeBox
Open Graph Description: Type: Bug Attempt to use the Instantiation Expressions in VSCode typescript language function makeBox
X Description: Type: Bug Attempt to use the Instantiation Expressions in VSCode typescript language function makeBox<T>(value: T){ return {value}; } const makeStringBox = makeBox<string>; const string...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/50161
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Instantiation expressions inconsistently trigger incorrect error messages in editor contexts","articleBody":"\r\nType: \u003cb>Bug\u003c/b>\r\n\r\n1. Attempt to use the Instantiation Expressions in VSCode typescript language\r\n\r\n```ts\r\nfunction makeBox\u003cT>(value: T){\r\n return {value};\r\n}\r\n\r\nconst makeStringBox = makeBox\u003cstring>;\r\nconst stringBox = makeStringBox('abc');\r\n```\r\n2. Observe Red squiggly lines that shouldn't be there.\r\n\r\n\r\n\r\n\r\nVS Code version: Code - Insiders 1.70.0-insider (e9bda7aa4ff76648cfccc1a7bde465443803da71, 2022-08-02T16:56:25.649Z)\r\nOS version: Windows_NT x64 10.0.19044\r\nModes:\r\n\r\n\u003cdetails>\r\n\u003csummary>System Info\u003c/summary>\r\n\r\n|Item|Value|\r\n|---|---|\r\n|CPUs|Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (16 x 3600)|\r\n|GPU Status|2d_canvas: enabled\u003cbr>canvas_oop_rasterization: disabled_off\u003cbr>direct_rendering_display_compositor: disabled_off_ok\u003cbr>gpu_compositing: enabled\u003cbr>multiple_raster_threads: enabled_on\u003cbr>opengl: enabled_on\u003cbr>rasterization: enabled\u003cbr>raw_draw: disabled_off_ok\u003cbr>skia_renderer: enabled_on\u003cbr>video_decode: enabled\u003cbr>video_encode: enabled\u003cbr>vulkan: disabled_off\u003cbr>webgl: enabled\u003cbr>webgl2: enabled|\r\n|Load (avg)|undefined|\r\n|Memory (System)|31.92GB (17.88GB free)|\r\n|Process Argv||\r\n|Screen Reader|no|\r\n|VM|0%|\r\n\u003c/details>Extensions: none\u003cdetails>\r\n\u003csummary>A/B Experiments\u003c/summary>\r\n\r\n```\r\nvsliv695:30137379\r\nvsins829:30139715\r\nvsliv368:30146709\r\nvsreu685:30147344\r\npython383:30185418\r\nvspor879:30202332\r\nvspor708:30202333\r\nvspor363:30204092\r\nvslsvsres303:30308271\r\npythonvspyl392:30422396\r\npythontb:30258533\r\npythonptprofiler:30281269\r\nvsdfh931:30280409\r\nvshan820:30294714\r\npythondataviewer:30285072\r\nvscod805:30301674\r\nbridge0708:30335490\r\nbridge0723:30353136\r\nvsaa593cf:30376535\r\npythonvs932:30404738\r\nwslgetstarted:30449409\r\nvscscmwlcmt:30465136\r\ncppdebug:30492333\r\nvscaac:30438845\r\npylanb8912:30522163\r\nvsclangdf:30492506\r\nc4g48928:30535728\r\n\r\n```\r\n\r\n\u003c/details>\r\n\r\n\u003c!-- generated by issue reporter -->\r\n\r\n\r\nI've had this issue with both no npm packages installed. With typescript installed only. And with typescript and a tsconfig.json file.\r\n\r\nNote: It is _incredibly_ inconsistent. Sometimes it doesn't happen. Other times changing from the built-in version of typescript to the local version fixes it, sometimes just waiting fixes it. Until you change the code at all (adding/removing whitespace for example) and then it comes back. Installing a different version of typescript removes the error until you change the code as well.\r\n\r\nI believe that this is a VSCode centric issue and not a Typescript issue for 2 reasons.\r\n1. Running `npx tsc` builds the package just fine without any issues from type errors.\r\n2. As seen in this comment, the typescript playground doesn't show any errors with this. https://github.com/microsoft/TypeScript/pull/47607#issuecomment-1191409426 [TS Playground](https://www.typescriptlang.org/play?target=99&moduleResolution=99&ts=4.7.4&jsx=0&jsxImportSource=true#code/GYVwdgxgLglg9mABAWwIYGsCmAhOAPAHgBUA+ACgDdUAbETALkSIEoBvAKES8QCdMoQPJKyq1MAXwDc7ce3YB6eYgB6AfnYQEAZygoMmAMpQeMMAHNceRAF49WSwR0nzJaZrA7ET0xfw27hsY+lmQA5KgARhChzNKKKuoa2roAojw8cDwAsqgADv45uY5B5gA0aRk8rkkeupjpmYX+YJgA7ogVjXlksXLsQA)\r\n","author":{"url":"https://github.com/ZachHaber","@type":"Person","name":"ZachHaber"},"datePublished":"2022-08-03T03:40:46Z","url":"https://github.com/microsoft/TypeScript/issues/50161"}
| 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:10a121ab-062f-89c1-df5a-4eb50aa1f517 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE96:291B58:185714E:1ECD77E:6B017D00 |
| html-safe-nonce | 9da4214ecba5de3a167821038e6ed95768f7db11e442e76415612cf5179f3c48 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTk2OjI5MUI1ODoxODU3MTRFOjFFQ0Q3N0U6NkIwMTdEMDAiLCJ2aXNpdG9yX2lkIjoiNjMwNjg1NDE2MjkwMzUyMzg1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fcd3fb42acdfee393a0a1c623ae28b67f3600b5bfc407ed296674d59c8c846e0 |
| hovercard-subject-tag | issue:1327349029 |
| 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/50161/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ec24b14f739dfe6622c12f7e193eca2c4f7f68da87ed9fd90c87b160fa4c14a3/microsoft/TypeScript/issues/50161 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ec24b14f739dfe6622c12f7e193eca2c4f7f68da87ed9fd90c87b160fa4c14a3/microsoft/TypeScript/issues/50161 |
| og:image:alt | Type: Bug Attempt to use the Instantiation Expressions in VSCode typescript language function makeBox |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ZachHaber |
| 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