@@ -2340,7 +2340,7 @@ module.exports = __toCommonJS(server_exports);
2340
2340
2341
2341
// src/compiler/corePublic.ts
2342
2342
var versionMajorMinor = "5.4";
2343
- var version = "5.4.2 ";
2343
+ var version = "5.4.3 ";
2344
2344
var Comparison = /* @__PURE__ */ ((Comparison3) => {
2345
2345
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2346
2346
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -62710,7 +62710,7 @@ function createTypeChecker(host) {
62710
62710
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
62711
62711
const typeVariable = typeSet[typeVarIndex];
62712
62712
const primitiveType = typeSet[1 - typeVarIndex];
62713
- if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
62713
+ if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) && !isGenericStringLikeType(primitiveType) || includes & 16777216 /* IncludesEmptyObject */)) {
62714
62714
const constraint = getBaseConstraintOfType(typeVariable);
62715
62715
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
62716
62716
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
@@ -63318,6 +63318,9 @@ function createTypeChecker(host) {
63318
63318
function isPatternLiteralType(type) {
63319
63319
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
63320
63320
}
63321
+ function isGenericStringLikeType(type) {
63322
+ return !!(type.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type);
63323
+ }
63321
63324
function isGenericType(type) {
63322
63325
return !!getGenericObjectFlags(type);
63323
63326
}
@@ -63340,7 +63343,7 @@ function createTypeChecker(host) {
63340
63343
}
63341
63344
return type.objectFlags & 12582912 /* IsGenericType */;
63342
63345
}
63343
- return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType (type) ? 8388608 /* IsGenericIndexType */ : 0);
63346
+ return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */) || isGenericStringLikeType (type) ? 8388608 /* IsGenericIndexType */ : 0);
63344
63347
}
63345
63348
function getSimplifiedType(type, writing) {
63346
63349
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -70388,7 +70391,7 @@ function createTypeChecker(host) {
70388
70391
function hasMatchingArgument(expression, reference) {
70389
70392
if (expression.arguments) {
70390
70393
for (const argument of expression.arguments) {
70391
- if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference) || getCandidateDiscriminantPropertyAccess(argument, reference) ) {
70394
+ if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
70392
70395
return true;
70393
70396
}
70394
70397
}
@@ -70398,36 +70401,6 @@ function createTypeChecker(host) {
70398
70401
}
70399
70402
return false;
70400
70403
}
70401
- function getCandidateDiscriminantPropertyAccess(expr, reference) {
70402
- if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
70403
- if (isIdentifier(expr)) {
70404
- const symbol = getResolvedSymbol(expr);
70405
- const declaration = symbol.valueDeclaration;
70406
- if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
70407
- return declaration;
70408
- }
70409
- }
70410
- } else if (isAccessExpression(expr)) {
70411
- if (isMatchingReference(reference, expr.expression)) {
70412
- return expr;
70413
- }
70414
- } else if (isIdentifier(expr)) {
70415
- const symbol = getResolvedSymbol(expr);
70416
- if (isConstantVariable(symbol)) {
70417
- const declaration = symbol.valueDeclaration;
70418
- if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
70419
- return declaration.initializer;
70420
- }
70421
- if (isBindingElement(declaration) && !declaration.initializer) {
70422
- const parent2 = declaration.parent.parent;
70423
- if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
70424
- return declaration;
70425
- }
70426
- }
70427
- }
70428
- }
70429
- return void 0;
70430
- }
70431
70404
function getFlowNodeId(flow) {
70432
70405
if (!flow.id || flow.id < 0) {
70433
70406
flow.id = nextFlowId;
@@ -71527,9 +71500,39 @@ function createTypeChecker(host) {
71527
71500
}
71528
71501
return result;
71529
71502
}
71503
+ function getCandidateDiscriminantPropertyAccess(expr) {
71504
+ if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
71505
+ if (isIdentifier(expr)) {
71506
+ const symbol = getResolvedSymbol(expr);
71507
+ const declaration = symbol.valueDeclaration;
71508
+ if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
71509
+ return declaration;
71510
+ }
71511
+ }
71512
+ } else if (isAccessExpression(expr)) {
71513
+ if (isMatchingReference(reference, expr.expression)) {
71514
+ return expr;
71515
+ }
71516
+ } else if (isIdentifier(expr)) {
71517
+ const symbol = getResolvedSymbol(expr);
71518
+ if (isConstantVariable(symbol)) {
71519
+ const declaration = symbol.valueDeclaration;
71520
+ if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
71521
+ return declaration.initializer;
71522
+ }
71523
+ if (isBindingElement(declaration) && !declaration.initializer) {
71524
+ const parent2 = declaration.parent.parent;
71525
+ if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
71526
+ return declaration;
71527
+ }
71528
+ }
71529
+ }
71530
+ }
71531
+ return void 0;
71532
+ }
71530
71533
function getDiscriminantPropertyAccess(expr, computedType) {
71531
71534
if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
71532
- const access = getCandidateDiscriminantPropertyAccess(expr, reference );
71535
+ const access = getCandidateDiscriminantPropertyAccess(expr);
71533
71536
if (access) {
71534
71537
const name = getAccessedPropertyName(access);
71535
71538
if (name) {
@@ -77250,7 +77253,7 @@ function createTypeChecker(host) {
77250
77253
}
77251
77254
return resolveErrorCall(node);
77252
77255
}
77253
- if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor )) {
77256
+ if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction )) {
77254
77257
skippedGenericFunction(node, checkMode);
77255
77258
return resolvingSignature;
77256
77259
}
@@ -77260,12 +77263,8 @@ function createTypeChecker(host) {
77260
77263
}
77261
77264
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
77262
77265
}
77263
- function isGenericFunctionReturningFunctionOrConstructor(signature) {
77264
- if (!signature.typeParameters) {
77265
- return false;
77266
- }
77267
- const returnType = getReturnTypeOfSignature(signature);
77268
- return isFunctionType(returnType) || isConstructorType(returnType);
77266
+ function isGenericFunctionReturningFunction(signature) {
77267
+ return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
77269
77268
}
77270
77269
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
77271
77270
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
0 commit comments