Fix bug: don't return string literal completions if there's no contextual type (#23079)

This commit is contained in:
Andy
2018-04-02 16:20:51 -07:00
committed by GitHub
parent 5a32fb0b07
commit d07102e567
2 changed files with 9 additions and 1 deletions

View File

@@ -388,7 +388,7 @@ namespace ts.Completions {
// '/*completion position*/'
// });
const type = typeChecker.getContextualType(node.parent.parent);
return { kind: StringLiteralCompletionKind.Properties, symbols: type && type.getApparentProperties() };
return type && { kind: StringLiteralCompletionKind.Properties, symbols: type.getApparentProperties() };
}
return fromContextualType();

View File

@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////const x = { "/**/" };
// We specifically filter out any array-like types.
// Private members will be excluded by `createUnionOrIntersectionProperty`.
goTo.marker("");
verify.completionListIsEmpty();