@@ -2340,7 +2340,7 @@ module.exports = __toCommonJS(server_exports);
23402340
23412341// src/compiler/corePublic.ts
23422342var versionMajorMinor = "5.4";
2343- var version = "5.4.2 ";
2343+ var version = "5.4.3 ";
23442344var Comparison = /* @__PURE__ */ ((Comparison3) => {
23452345 Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
23462346 Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -62710,7 +62710,7 @@ function createTypeChecker(host) {
6271062710 const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
6271162711 const typeVariable = typeSet[typeVarIndex];
6271262712 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 */)) {
6271462714 const constraint = getBaseConstraintOfType(typeVariable);
6271562715 if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
6271662716 if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
@@ -63318,6 +63318,9 @@ function createTypeChecker(host) {
6331863318 function isPatternLiteralType(type) {
6331963319 return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
6332063320 }
63321+ function isGenericStringLikeType(type) {
63322+ return !!(type.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type);
63323+ }
6332163324 function isGenericType(type) {
6332263325 return !!getGenericObjectFlags(type);
6332363326 }
@@ -63340,7 +63343,7 @@ function createTypeChecker(host) {
6334063343 }
6334163344 return type.objectFlags & 12582912 /* IsGenericType */;
6334263345 }
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);
6334463347 }
6334563348 function getSimplifiedType(type, writing) {
6334663349 return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -70388,7 +70391,7 @@ function createTypeChecker(host) {
7038870391 function hasMatchingArgument(expression, reference) {
7038970392 if (expression.arguments) {
7039070393 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)) {
7039270395 return true;
7039370396 }
7039470397 }
@@ -70398,36 +70401,6 @@ function createTypeChecker(host) {
7039870401 }
7039970402 return false;
7040070403 }
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- }
7043170404 function getFlowNodeId(flow) {
7043270405 if (!flow.id || flow.id < 0) {
7043370406 flow.id = nextFlowId;
@@ -71527,9 +71500,39 @@ function createTypeChecker(host) {
7152771500 }
7152871501 return result;
7152971502 }
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+ }
7153071533 function getDiscriminantPropertyAccess(expr, computedType) {
7153171534 if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
71532- const access = getCandidateDiscriminantPropertyAccess(expr, reference );
71535+ const access = getCandidateDiscriminantPropertyAccess(expr);
7153371536 if (access) {
7153471537 const name = getAccessedPropertyName(access);
7153571538 if (name) {
@@ -77250,7 +77253,7 @@ function createTypeChecker(host) {
7725077253 }
7725177254 return resolveErrorCall(node);
7725277255 }
77253- if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor )) {
77256+ if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction )) {
7725477257 skippedGenericFunction(node, checkMode);
7725577258 return resolvingSignature;
7725677259 }
@@ -77260,12 +77263,8 @@ function createTypeChecker(host) {
7726077263 }
7726177264 return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
7726277265 }
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)));
7726977268 }
7727077269 function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
7727177270 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