Found while reading over #39697
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
|
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)); |
Found while reading over #39697
Request completions inside of
""and you'll get the names of every propery onString. 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
ifcheck atTypeScript/src/services/stringCompletions.ts
Lines 117 to 124 in d75894d