@@ -1641,8 +1641,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1641
1641
getFullyQualifiedName,
1642
1642
getResolvedSignature: (node, candidatesOutArray, argumentCount) =>
1643
1643
getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.Normal),
1644
- getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray) =>
1645
- runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, CheckMode.IsForStringLiteralArgumentCompletions)),
1644
+ getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray, checkMode = CheckMode.IsForStringLiteralArgumentCompletions) => {
1645
+ if (checkMode & CheckMode.IsForStringLiteralArgumentCompletions) {
1646
+ return runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, checkMode & ~CheckMode.IsForStringLiteralArgumentCompletions));
1647
+ }
1648
+ return runWithoutResolvedSignatureCaching(editingArgument, () => getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, checkMode & ~CheckMode.IsForStringLiteralArgumentCompletions));
1649
+ },
1646
1650
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) =>
1647
1651
runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.IsForSignatureHelp)),
1648
1652
getExpandedParameters,
@@ -25230,7 +25234,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
25230
25234
const constraint = getConstraintOfTypeParameter(inference.typeParameter);
25231
25235
if (constraint) {
25232
25236
const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
25233
- if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
25237
+ if (!inferredType || inferredType === wildcardType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
25234
25238
// If the fallback type satisfies the constraint, we pick it. Otherwise, we pick the constraint.
25235
25239
inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
25236
25240
}
@@ -32508,7 +32512,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
32508
32512
32509
32513
for (let i = 0; i < argCount; i++) {
32510
32514
const arg = args[i];
32511
- if (arg.kind !== SyntaxKind.OmittedExpression && !(checkMode & CheckMode.IsForStringLiteralArgumentCompletions && hasSkipDirectInferenceFlag(arg)) ) {
32515
+ if (arg.kind !== SyntaxKind.OmittedExpression) {
32512
32516
const paramType = getTypeAtPosition(signature, i);
32513
32517
if (couldContainTypeVariables(paramType)) {
32514
32518
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -33152,7 +33156,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
33152
33156
// decorators are applied to a declaration by the emitter, and not to an expression.
33153
33157
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
33154
33158
let argCheckMode = !isDecorator && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? CheckMode.SkipContextSensitive : CheckMode.Normal;
33155
- argCheckMode |= checkMode & CheckMode.IsForStringLiteralArgumentCompletions;
33156
33159
33157
33160
// The following variables are captured and modified by calls to chooseOverload.
33158
33161
// If overload resolution or type argument inference fails, we want to report the
@@ -33391,7 +33394,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
33391
33394
// If one or more context sensitive arguments were excluded, we start including
33392
33395
// them now (and keeping do so for any subsequent candidates) and perform a second
33393
33396
// round of type inference and applicability checking for this particular candidate.
33394
- argCheckMode = checkMode & CheckMode.IsForStringLiteralArgumentCompletions ;
33397
+ argCheckMode = CheckMode.Normal ;
33395
33398
if (inferenceContext) {
33396
33399
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
33397
33400
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
@@ -37901,7 +37904,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
37901
37904
case SyntaxKind.NoSubstitutionTemplateLiteral:
37902
37905
case SyntaxKind.StringLiteral:
37903
37906
return hasSkipDirectInferenceFlag(node) ?
37904
- anyType :
37907
+ wildcardType :
37905
37908
getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text));
37906
37909
case SyntaxKind.NumericLiteral:
37907
37910
checkGrammarNumericLiteral(node as NumericLiteral);
0 commit comments