@@ -1256,8 +1256,7 @@ export const enum CheckMode {
1256
1256
SkipContextSensitive = 1 << 2, // Skip context sensitive function expressions
1257
1257
SkipGenericFunctions = 1 << 3, // Skip single signature generic functions
1258
1258
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
1261
1260
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
1262
1261
// we need to preserve generic types instead of substituting them for constraints
1263
1262
}
@@ -1658,7 +1657,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1658
1657
getResolvedSignature: (node, candidatesOutArray, argumentCount) =>
1659
1658
getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.Normal),
1660
1659
getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray) =>
1661
- runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, CheckMode.IsForStringLiteralArgumentCompletions )),
1660
+ runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, CheckMode.Normal )),
1662
1661
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) =>
1663
1662
runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.IsForSignatureHelp)),
1664
1663
getExpandedParameters,
@@ -25198,7 +25197,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
25198
25197
const constraint = getConstraintOfTypeParameter(inference.typeParameter);
25199
25198
if (constraint) {
25200
25199
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))) {
25202
25201
inference.inferredType = inferredType = instantiatedConstraint;
25203
25202
}
25204
25203
}
@@ -32436,7 +32435,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
32436
32435
32437
32436
for (let i = 0; i < argCount; i++) {
32438
32437
const arg = args[i];
32439
- if (arg.kind !== SyntaxKind.OmittedExpression && !(checkMode & CheckMode.IsForStringLiteralArgumentCompletions && hasSkipDirectInferenceFlag(arg)) ) {
32438
+ if (arg.kind !== SyntaxKind.OmittedExpression) {
32440
32439
const paramType = getTypeAtPosition(signature, i);
32441
32440
if (couldContainTypeVariables(paramType)) {
32442
32441
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -33079,7 +33078,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
33079
33078
// decorators are applied to a declaration by the emitter, and not to an expression.
33080
33079
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
33081
33080
let argCheckMode = !isDecorator && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? CheckMode.SkipContextSensitive : CheckMode.Normal;
33082
- argCheckMode |= checkMode & CheckMode.IsForStringLiteralArgumentCompletions;
33083
33081
33084
33082
// The following variables are captured and modified by calls to chooseOverload.
33085
33083
// If overload resolution or type argument inference fails, we want to report the
@@ -33318,7 +33316,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
33318
33316
// If one or more context sensitive arguments were excluded, we start including
33319
33317
// them now (and keeping do so for any subsequent candidates) and perform a second
33320
33318
// round of type inference and applicability checking for this particular candidate.
33321
- argCheckMode = checkMode & CheckMode.IsForStringLiteralArgumentCompletions ;
33319
+ argCheckMode = CheckMode.Normal ;
33322
33320
if (inferenceContext) {
33323
33321
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
33324
33322
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
@@ -37803,7 +37801,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
37803
37801
case SyntaxKind.NoSubstitutionTemplateLiteral:
37804
37802
case SyntaxKind.StringLiteral:
37805
37803
return hasSkipDirectInferenceFlag(node) ?
37806
- anyType :
37804
+ wildcardType :
37807
37805
getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text));
37808
37806
case SyntaxKind.NumericLiteral:
37809
37807
checkGrammarNumericLiteral(node as NumericLiteral);
0 commit comments