mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 00:55:32 -05:00
fix(40322): bad completions for string literal type as indexed access type object (#40424)
* Added fourslash tests to work on the bug * fix(40322): bad completions for string literal type as indexed access type object * Added regression tests * Using nodes instead of text * Add verification for parenthesized nodes * Using range check * Change test markers
This commit is contained in:
@@ -130,7 +130,11 @@ namespace ts.Completions.StringCompletions {
|
||||
// bar: string;
|
||||
// }
|
||||
// let x: Foo["/*completion position*/"]
|
||||
return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode((grandParent as IndexedAccessTypeNode).objectType));
|
||||
const { indexType, objectType } = grandParent as IndexedAccessTypeNode;
|
||||
if (!rangeContainsPosition(indexType, position)) {
|
||||
return undefined;
|
||||
}
|
||||
return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType));
|
||||
case SyntaxKind.ImportType:
|
||||
return { kind: StringLiteralCompletionKind.Paths, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) };
|
||||
case SyntaxKind.UnionType: {
|
||||
|
||||
Reference in New Issue
Block a user