Skip to content

Commit 089876a

Browse files
authored
Retry string completions from the inferred type by default (#53481)
1 parent 6e44db7 commit 089876a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/services/stringCompletions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringL
440440
const literals = contextualTypes.types.filter(literal => !tracker.hasValue(literal.value));
441441
return { kind: StringLiteralCompletionKind.Types, types: literals, isNewIdentifier: false };
442442
default:
443-
return fromContextualType();
443+
return fromContextualType() || fromContextualType(ContextFlags.None);
444444
}
445445

446446
function fromContextualType(contextFlags: ContextFlags = ContextFlags.Completions): StringLiteralCompletionsFromTypes | undefined {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
//// declare function test<T>(a: {
4+
//// [K in keyof T]: {
5+
//// b?: (keyof T)[];
6+
//// };
7+
//// }): void;
8+
////
9+
//// test({
10+
//// foo: {},
11+
//// bar: {
12+
//// b: ["/*ts*/"],
13+
//// },
14+
//// });
15+
16+
verify.completions({ marker: ["ts"], exact: ["foo", "bar"] });

0 commit comments

Comments
 (0)