fix(37364): show completions for string literal index on mapped type (#37367)

This commit is contained in:
Alexander T 2020-04-10 19:36:26 +03:00 committed by GitHub
parent 52dc9f2282
commit aa6be6ee6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -223,7 +223,9 @@ namespace ts.Completions.StringCompletions {
function stringLiteralCompletionsFromProperties(type: Type | undefined): StringLiteralCompletionsFromProperties | undefined {
return type && {
kind: StringLiteralCompletionKind.Properties,
symbols: type.getApparentProperties().filter(prop => !isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)),
symbols: type.getApparentProperties().filter(prop =>
!isPrivateIdentifierPropertyDeclaration(
isTransientSymbol(prop) && prop.syntheticOrigin ? prop.syntheticOrigin.valueDeclaration : prop.valueDeclaration)),
hasIndexSignature: hasIndexSignature(type)
};
}

View File

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts'/>
////type Foo = {
//// a: string;
//// b: string;
////};
////
////type A = Readonly<Foo>;
////type B = A["[|/**/|]"]
const replacementSpan = test.ranges()[0];
verify.completions({
marker: "",
exact: [
{ name: "a", replacementSpan },
{ name: "b", replacementSpan }
]
});