-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this
Milestone
Description
Found while reading over #39697
let x: ""["bar"]
Request completions inside of ""
and you'll get the names of every propery on String
. What's happening is that we're not checking to see if the current string literal type is the argument type (as opposed to the object type itself).
Learning how this works might be a bit involved, but the fix is easy: add fourslash tests, add a single if
check at
TypeScript/src/services/stringCompletions.ts
Lines 117 to 124 in d75894d
case SyntaxKind.IndexedAccessType: | |
// Get all apparent property names | |
// i.e. interface Foo { | |
// foo: string; | |
// bar: string; | |
// } | |
// let x: Foo["/*completion position*/"] | |
return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode((parent.parent as IndexedAccessTypeNode).objectType)); |
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this