@@ -1258,11 +1258,10 @@ export const enum CheckMode {
1258
1258
SkipContextSensitive = 1 << 2, // Skip context sensitive function expressions
1259
1259
SkipGenericFunctions = 1 << 3, // Skip single signature generic functions
1260
1260
IsForSignatureHelp = 1 << 4, // Call resolution for purposes of signature help
1261
- IsForStringLiteralArgumentCompletions = 1 << 5, // Do not infer from the argument currently being typed
1262
- RestBindingElement = 1 << 6, // Checking a type that is going to be used to determine the type of a rest binding element
1261
+ RestBindingElement = 1 << 5, // Checking a type that is going to be used to determine the type of a rest binding element
1263
1262
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
1264
1263
// we need to preserve generic types instead of substituting them for constraints
1265
- TypeOnly = 1 << 7 , // Called from getTypeOfExpression, diagnostics may be omitted
1264
+ TypeOnly = 1 << 6 , // Called from getTypeOfExpression, diagnostics may be omitted
1266
1265
}
1267
1266
1268
1267
/** @internal */
@@ -1836,7 +1835,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1836
1835
const candidates: Signature[] = [];
1837
1836
1838
1837
// first, get candidates when inference is blocked from the source node.
1839
- runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(call, candidates, /*argumentCount*/ undefined, CheckMode.IsForStringLiteralArgumentCompletions ));
1838
+ runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(call, candidates, /*argumentCount*/ undefined, CheckMode.Normal ));
1840
1839
for (const candidate of candidates) {
1841
1840
candidatesSet.add(candidate);
1842
1841
}
@@ -24913,7 +24912,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
24913
24912
if (!couldContainTypeVariables(target)) {
24914
24913
return;
24915
24914
}
24916
- if (source === wildcardType) {
24915
+ if (source === wildcardType || source === blockedStringType ) {
24917
24916
// We are inferring from an 'any' type. We want to infer this type for every type parameter
24918
24917
// referenced in the target type, so we record it as the propagation type and infer from the
24919
24918
// target to itself. Then, as we find candidates we substitute the propagation type.
@@ -25013,14 +25012,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
25013
25012
return;
25014
25013
}
25015
25014
if (!inference.isFixed) {
25015
+ const candidate = propagationType || source;
25016
+ if (candidate === blockedStringType) {
25017
+ return;
25018
+ }
25016
25019
if (inference.priority === undefined || priority < inference.priority) {
25017
25020
inference.candidates = undefined;
25018
25021
inference.contraCandidates = undefined;
25019
25022
inference.topLevel = true;
25020
25023
inference.priority = priority;
25021
25024
}
25022
25025
if (priority === inference.priority) {
25023
- const candidate = propagationType || source;
25024
25026
// We make contravariant inferences only if we are in a pure contravariant position,
25025
25027
// i.e. only if we have not descended into a bivariant position.
25026
25028
if (contravariant && !bivariant) {
@@ -25753,7 +25755,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
25753
25755
const constraint = getConstraintOfTypeParameter(inference.typeParameter);
25754
25756
if (constraint) {
25755
25757
const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
25756
- if (!inferredType || inferredType === blockedStringType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
25758
+ if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
25757
25759
// If the fallback type satisfies the constraint, we pick it. Otherwise, we pick the constraint.
25758
25760
inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
25759
25761
}
@@ -33123,7 +33125,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
33123
33125
33124
33126
for (let i = 0; i < argCount; i++) {
33125
33127
const arg = args[i];
33126
- if (arg.kind !== SyntaxKind.OmittedExpression && !(checkMode & CheckMode.IsForStringLiteralArgumentCompletions && hasSkipDirectInferenceFlag(arg)) ) {
33128
+ if (arg.kind !== SyntaxKind.OmittedExpression) {
33127
33129
const paramType = getTypeAtPosition(signature, i);
33128
33130
if (couldContainTypeVariables(paramType)) {
33129
33131
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -33765,7 +33767,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
33765
33767
// decorators are applied to a declaration by the emitter, and not to an expression.
33766
33768
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
33767
33769
let argCheckMode = !isDecorator && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? CheckMode.SkipContextSensitive : CheckMode.Normal;
33768
- argCheckMode |= checkMode & CheckMode.IsForStringLiteralArgumentCompletions;
33769
33770
33770
33771
// The following variables are captured and modified by calls to chooseOverload.
33771
33772
// If overload resolution or type argument inference fails, we want to report the
0 commit comments