Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af30c79

Browse files
authored
Fixed string literal completions for partially-typed strings when overload could get matched (microsoft#48811)
1 parent 71f94c5 commit af30c79

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/compiler/checker.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -30501,6 +30501,7 @@ namespace ts {
3050130501
// decorators are applied to a declaration by the emitter, and not to an expression.
3050230502
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
3050330503
let argCheckMode = !isDecorator && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? CheckMode.SkipContextSensitive : CheckMode.Normal;
30504+
argCheckMode |= checkMode & CheckMode.IsForStringLiteralArgumentCompletions;
3050430505

3050530506
// The following variables are captured and modified by calls to chooseOverload.
3050630507
// If overload resolution or type argument inference fails, we want to report the
@@ -30726,7 +30727,7 @@ namespace ts {
3072630727
// If one or more context sensitive arguments were excluded, we start including
3072730728
// them now (and keeping do so for any subsequent candidates) and perform a second
3072830729
// round of type inference and applicability checking for this particular candidate.
30729-
argCheckMode = CheckMode.Normal;
30730+
argCheckMode = checkMode & CheckMode.IsForStringLiteralArgumentCompletions;
3073030731
if (inferenceContext) {
3073130732
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
3073230733
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @Filename: /a.tsx
4+
//// declare function bar1<P extends "" | "bar" | "baz">(p: P): void;
5+
////
6+
//// bar1("/*ts*/")
7+
////
8+
9+
verify.completions({ marker: ["ts"], exact: ["", "bar", "baz"] });

0 commit comments

Comments
 (0)