Title: Inaccurate Intellisense / Suggestions with Function Overloads · Issue #51047 · microsoft/TypeScript · GitHub
Open Graph Title: Inaccurate Intellisense / Suggestions with Function Overloads · Issue #51047 · microsoft/TypeScript
X Title: Inaccurate Intellisense / Suggestions with Function Overloads · Issue #51047 · microsoft/TypeScript
Description: Does this issue occur when all extensions are disabled?: Yes VS Code Version: Version: 1.69.1 (system setup) Commit: b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a Date: 2022-07-12T08:21:24.514Z Electron: 18.3.5 Chromium: 100.0.4896.160 Node.j...
Open Graph Description: Does this issue occur when all extensions are disabled?: Yes VS Code Version: Version: 1.69.1 (system setup) Commit: b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a Date: 2022-07-12T08:21:24.514Z Electron...
X Description: Does this issue occur when all extensions are disabled?: Yes VS Code Version: Version: 1.69.1 (system setup) Commit: b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a Date: 2022-07-12T08:21:24.514Z Electron...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/51047
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inaccurate Intellisense / Suggestions with Function Overloads","articleBody":"\u003c!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->\r\n\u003c!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->\r\n\u003c!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->\r\n\u003c!-- 🔎 Search existing issues to avoid creating duplicates. -->\r\n\u003c!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->\r\n\u003c!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->\r\n\u003c!-- 🔧 Launch with `code --disable-extensions` to check. -->\r\nDoes this issue occur when all extensions are disabled?: Yes\r\n\r\n\u003c!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->\r\n\u003c!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->\r\n- VS Code Version:\r\nVersion: 1.69.1 (system setup)\r\nCommit: b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a\r\nDate: 2022-07-12T08:21:24.514Z\r\nElectron: 18.3.5\r\nChromium: 100.0.4896.160\r\nNode.js: 16.13.2\r\nV8: 10.0.139.17-electron.0\r\nOS: Windows_NT x64 10.0.19044\r\n\r\nSteps to Reproduce:\r\n1. Go to [this playground](https://www.typescriptlang.org/play?ts=4.7.4&ssl=25&ssc=67&pln=1&pc=1#code/GYVwdgxgLglg9mABAEzgZTgWwKZQBYxgDmAPACoCeADtotgB5TZjIDOicARgFbbQA0iANLYKdRszaIA1qLjBElGgD4AFAChEiGE0wAuRdWz9NiAHQXZFVgZEUA2gF11ASgMA3ODGQBudetBIWAQUdCxcAmJyI3EmFnYuXgFhUVjJdit5QxUNLR1sTBts7CcTLQszKyK7J1cPL19-QOh4JFQMHHxCUiVaBjipRL4oQTs0+Jk5BV61U3zMAHkAJwBJXSLesvNLUWrRWpdEAG9TAHpTjkwdJmREYDglxE4l7HcdCnUAX38oGIAxOBwRAAXmOpgAhgYwCBMJxsEs-FpOFCYXCEaYIAZWFAlt0-J8-OoIAhsYh6CDQh0It1VEdEJDEABGQTIxAAJkEmMQACJuYhPvT2AC4IJueDuaLOBKeRBuS4-MSwKSxKD2uEusRVPY6QzmU8DBzEFzefzHILEMLSjzxaLZfL1EA) and/or create a new TypeScript file with the code snippet shared below\r\n2. After `\"c\"` on the last line, type `, \"i\"`\r\n3. Note the intellisense and suggestions\r\n\r\nApologies, there's probably a better title for this issue...\r\n\r\nI thought this might be a better issue for Monaco, but their issue template said that if I could recreate the issue in VS Code to open the issue here. Maybe this should be a TS issue instead since its reproducible in the playground as well? However, the TypeScript seems to be working fine, it's just the intellisense that seems to be confused.\r\n\r\nTake the following code:\r\n\r\n```ts\r\nfunction doSomething\u003cType extends object, Key extends keyof Type>(\r\n item: Type,\r\n ...keys: Key[]\r\n): void;\r\n\r\nfunction doSomething\u003cType extends object, Key extends keyof Type>(\r\n items: Type[],\r\n ...keys: Key[]\r\n): void;\r\n\r\nfunction doSomething\u003cType extends object, Key extends keyof Type>(\r\n itemOrItems: Type,\r\n ...keys: Key[]\r\n) {\r\n // omitted for brevity\r\n}\r\n\r\ntype Foo = {\r\n a: number;\r\n b: number;\r\n c: string;\r\n};\r\n\r\nconst x = doSomething({ a: 1, b: 2, c: \"\" } as Foo, \"a\", \"b\", \"c\");\r\nconst y = doSomething([{ a: 1, b: 2, c: \"\" }] as Foo[], \"a\", \"c\");\r\n```\r\n\r\nWhen spreading arguments into the function corresponding with the second overload, the intellisense provides inaccurate suggestions and incorrectly infers `...keys` as `(keyof Foo[])[]` when it should actually be `(keyof Foo)[]`:\r\n\r\n\r\n\r\nAgain, note that TypeScript is working as expected, and accepting any of the suggestions provided by the intellisense will result in a type error.","author":{"url":"https://github.com/no-stack-dub-sack","@type":"Person","name":"no-stack-dub-sack"},"datePublished":"2022-10-01T03:53:59Z","url":"https://github.com/microsoft/TypeScript/issues/51047"}
| 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:8d7d0e67-c310-d622-6124-aa4e352a140b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9970:EA06E:22052CF:2B4B501:6B016008 |
| html-safe-nonce | 25bd307991d1f8f47676df6fae96bcb2943c5ea903b54b16a0cef8e55a7446ed |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTcwOkVBMDZFOjIyMDUyQ0Y6MkI0QjUwMTo2QjAxNjAwOCIsInZpc2l0b3JfaWQiOiI5MjA4NTg2OTI3MjY2MTYwNjQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9ae30c2ab6ef3d31bc1eba366ab1cf56e864d60b729fb68fe3a2445a1abf5e24 |
| hovercard-subject-tag | issue:1395394400 |
| 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/51047/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c0ff81271a1798ef1099bbcae5db2292f94f964eaa156726dcfcd64a16f8345d/microsoft/TypeScript/issues/51047 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c0ff81271a1798ef1099bbcae5db2292f94f964eaa156726dcfcd64a16f8345d/microsoft/TypeScript/issues/51047 |
| og:image:alt | Does this issue occur when all extensions are disabled?: Yes VS Code Version: Version: 1.69.1 (system setup) Commit: b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a Date: 2022-07-12T08:21:24.514Z Electron... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | no-stack-dub-sack |
| 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