Skip to content

Commit 7ab8679

Browse files
committed
Root out CheckMode.IsForStringLiteralArgumentCompletions
1 parent 8749fb5 commit 7ab8679

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,8 +1256,7 @@ export const enum CheckMode {
12561256
SkipContextSensitive = 1 << 2, // Skip context sensitive function expressions
12571257
SkipGenericFunctions = 1 << 3, // Skip single signature generic functions
12581258
IsForSignatureHelp = 1 << 4, // Call resolution for purposes of signature help
1259-
IsForStringLiteralArgumentCompletions = 1 << 5, // Do not infer from the argument currently being typed
1260-
RestBindingElement = 1 << 6, // Checking a type that is going to be used to determine the type of a rest binding element
1259+
RestBindingElement = 1 << 5, // Checking a type that is going to be used to determine the type of a rest binding element
12611260
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
12621261
// we need to preserve generic types instead of substituting them for constraints
12631262
}
@@ -1658,7 +1657,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
16581657
getResolvedSignature: (node, candidatesOutArray, argumentCount) =>
16591658
getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.Normal),
16601659
getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray) =>
1661-
runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, CheckMode.IsForStringLiteralArgumentCompletions)),
1660+
runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, CheckMode.Normal)),
16621661
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) =>
16631662
runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.IsForSignatureHelp)),
16641663
getExpandedParameters,
@@ -25198,7 +25197,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2519825197
const constraint = getConstraintOfTypeParameter(inference.typeParameter);
2519925198
if (constraint) {
2520025199
const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
25201-
if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
25200+
if (!inferredType || inferredType === wildcardType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
2520225201
inference.inferredType = inferredType = instantiatedConstraint;
2520325202
}
2520425203
}
@@ -32436,7 +32435,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3243632435

3243732436
for (let i = 0; i < argCount; i++) {
3243832437
const arg = args[i];
32439-
if (arg.kind !== SyntaxKind.OmittedExpression && !(checkMode & CheckMode.IsForStringLiteralArgumentCompletions && hasSkipDirectInferenceFlag(arg))) {
32438+
if (arg.kind !== SyntaxKind.OmittedExpression) {
3244032439
const paramType = getTypeAtPosition(signature, i);
3244132440
if (couldContainTypeVariables(paramType)) {
3244232441
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -33079,7 +33078,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3307933078
// decorators are applied to a declaration by the emitter, and not to an expression.
3308033079
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
3308133080
let argCheckMode = !isDecorator && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? CheckMode.SkipContextSensitive : CheckMode.Normal;
33082-
argCheckMode |= checkMode & CheckMode.IsForStringLiteralArgumentCompletions;
3308333081

3308433082
// The following variables are captured and modified by calls to chooseOverload.
3308533083
// If overload resolution or type argument inference fails, we want to report the
@@ -33318,7 +33316,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3331833316
// If one or more context sensitive arguments were excluded, we start including
3331933317
// them now (and keeping do so for any subsequent candidates) and perform a second
3332033318
// round of type inference and applicability checking for this particular candidate.
33321-
argCheckMode = checkMode & CheckMode.IsForStringLiteralArgumentCompletions;
33319+
argCheckMode = CheckMode.Normal;
3332233320
if (inferenceContext) {
3332333321
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
3332433322
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
@@ -37803,7 +37801,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3780337801
case SyntaxKind.NoSubstitutionTemplateLiteral:
3780437802
case SyntaxKind.StringLiteral:
3780537803
return hasSkipDirectInferenceFlag(node) ?
37806-
anyType :
37804+
wildcardType :
3780737805
getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text));
3780837806
case SyntaxKind.NumericLiteral:
3780937807
checkGrammarNumericLiteral(node as NumericLiteral);

0 commit comments

Comments
 (0)