Retry string completions from the inferred type by default (#53481)

This commit is contained in:
Mateusz Burzyński
2023-03-27 18:21:03 -07:00
committed by GitHub
parent 6e44db7d1d
commit 089876a5c5
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -440,7 +440,7 @@ function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringL
const literals = contextualTypes.types.filter(literal => !tracker.hasValue(literal.value));
return { kind: StringLiteralCompletionKind.Types, types: literals, isNewIdentifier: false };
default:
return fromContextualType();
return fromContextualType() || fromContextualType(ContextFlags.None);
}
function fromContextualType(contextFlags: ContextFlags = ContextFlags.Completions): StringLiteralCompletionsFromTypes | undefined {
@@ -0,0 +1,16 @@
/// <reference path="fourslash.ts" />
//// declare function test<T>(a: {
//// [K in keyof T]: {
//// b?: (keyof T)[];
//// };
//// }): void;
////
//// test({
//// foo: {},
//// bar: {
//// b: ["/*ts*/"],
//// },
//// });
verify.completions({ marker: ["ts"], exact: ["foo", "bar"] });