diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index ec445e7aabc71..8548dbdbd323e 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -439,7 +439,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 { diff --git a/tests/cases/fourslash/completionsLiteralFromInferenceWithinInferredType3.ts b/tests/cases/fourslash/completionsLiteralFromInferenceWithinInferredType3.ts new file mode 100644 index 0000000000000..9cbe1777324d0 --- /dev/null +++ b/tests/cases/fourslash/completionsLiteralFromInferenceWithinInferredType3.ts @@ -0,0 +1,16 @@ +/// + +//// declare function test(a: { +//// [K in keyof T]: { +//// b?: (keyof T)[]; +//// }; +//// }): void; +//// +//// test({ +//// foo: {}, +//// bar: { +//// b: ["/*ts*/"], +//// }, +//// }); + +verify.completions({ marker: ["ts"], exact: ["foo", "bar"] });