From db3575ab8a91ef5401f7b05bd00ec85db7f0d51d Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Mon, 26 Jun 2023 16:24:54 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Pick=20PR=20#54588=20(Fixed=20a?= =?UTF-8?q?=20regression=20with=20string=20comp...)=20into=20release-5.1?= =?UTF-8?q?=20(#54635)?= 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 +- ...letionsLiteralDirectlyInRestConstrainedToArrayType.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/completionsLiteralDirectlyInRestConstrainedToArrayType.ts diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 61c23266701fa..e2250bee92f6f 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -387,7 +387,7 @@ function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringL // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") - return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType(); + return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType(ContextFlags.None); } // falls through (is `require("")` or `require(""` or `import("")`) diff --git a/tests/cases/fourslash/completionsLiteralDirectlyInRestConstrainedToArrayType.ts b/tests/cases/fourslash/completionsLiteralDirectlyInRestConstrainedToArrayType.ts new file mode 100644 index 0000000000000..620e4fda5f24d --- /dev/null +++ b/tests/cases/fourslash/completionsLiteralDirectlyInRestConstrainedToArrayType.ts @@ -0,0 +1,9 @@ +/// +// @strict: true +//// +//// function fn(...values: T): T { return values; } +//// +//// const value1 = fn('/*1*/'); +//// const value2 = fn('value1', '/*2*/'); + +verify.completions({ marker: ["1", "2"], includes: [`value1`, `value2`, `value3`] })