From 1e70bb8dc4be0eff311278765352913537350a48 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Tue, 28 Mar 2023 10:02:57 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Pick=20PR=20#53481=20(Retry=20st?= =?UTF-8?q?ring=20completions=20from=20the=20i...)=20into=20release-5.0=20?= =?UTF-8?q?(#53551)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mateusz BurzyƄski --- src/services/stringCompletions.ts | 2 +- ...onsLiteralFromInferenceWithinInferredType3.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/completionsLiteralFromInferenceWithinInferredType3.ts 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"] });