mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Update LKG
This commit is contained in:
+137
-29
@@ -6202,7 +6202,7 @@ var Diagnostics = {
|
||||
An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
|
||||
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
|
||||
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
|
||||
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
|
||||
The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_type_assignable_to_the_Function_interface_type_or_an_object_type_with_a_Symbol_hasInstance_method: diag(2359, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_2359", "The right-hand side of an 'instanceof' expression must be either of type 'any', a class, function, or other type assignable to the 'Function' interface type, or an object type with a 'Symbol.hasInstance' method."),
|
||||
The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, 1 /* Error */, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
|
||||
The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, 1 /* Error */, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
|
||||
The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, 1 /* Error */, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."),
|
||||
@@ -6651,6 +6651,8 @@ var Diagnostics = {
|
||||
Import_attributes_cannot_be_used_with_type_only_imports_or_exports: diag(2857, 1 /* Error */, "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857", "Import attributes cannot be used with type-only imports or exports."),
|
||||
Import_attribute_values_must_be_string_literal_expressions: diag(2858, 1 /* Error */, "Import_attribute_values_must_be_string_literal_expressions_2858", "Import attribute values must be string literal expressions."),
|
||||
Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."),
|
||||
The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method: diag(2860, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2860", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."),
|
||||
An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression: diag(2861, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2861", "An object's '[Symbol.hasInstance]' method must return a boolean value for it to be used on the right-hand side of an 'instanceof' expression."),
|
||||
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
||||
@@ -10813,7 +10815,14 @@ function isAccessor(node) {
|
||||
function isAutoAccessorPropertyDeclaration(node) {
|
||||
return isPropertyDeclaration(node) && hasAccessorModifier(node);
|
||||
}
|
||||
function isClassFieldAndNotAutoAccessor(node) {
|
||||
function isClassInstanceProperty(node) {
|
||||
if (isInJSFile(node) && isExpandoPropertyDeclaration(node)) {
|
||||
return (!isBindableStaticAccessExpression(node) || !isPrototypeAccess(node.expression)) && !isBindableStaticNameExpression(
|
||||
node,
|
||||
/*excludeThisKeyword*/
|
||||
true
|
||||
);
|
||||
}
|
||||
return node.parent && isClassLike(node.parent) && isPropertyDeclaration(node) && !hasAccessorModifier(node);
|
||||
}
|
||||
function isMethodOrAccessor(node) {
|
||||
@@ -13076,6 +13085,8 @@ function getInvokedExpression(node) {
|
||||
case 286 /* JsxOpeningElement */:
|
||||
case 285 /* JsxSelfClosingElement */:
|
||||
return node.tagName;
|
||||
case 226 /* BinaryExpression */:
|
||||
return node.right;
|
||||
default:
|
||||
return node.expression;
|
||||
}
|
||||
@@ -15582,6 +15593,12 @@ function isRightSideOfAccessExpression(node) {
|
||||
function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
|
||||
return isQualifiedName(node.parent) && node.parent.right === node || isPropertyAccessExpression(node.parent) && node.parent.name === node || isJSDocMemberName(node.parent) && node.parent.right === node;
|
||||
}
|
||||
function isInstanceOfExpression(node) {
|
||||
return isBinaryExpression(node) && node.operatorToken.kind === 104 /* InstanceOfKeyword */;
|
||||
}
|
||||
function isRightSideOfInstanceofExpression(node) {
|
||||
return isInstanceOfExpression(node.parent) && node === node.parent.right;
|
||||
}
|
||||
function isEmptyObjectLiteral(expression) {
|
||||
return expression.kind === 210 /* ObjectLiteralExpression */ && expression.properties.length === 0;
|
||||
}
|
||||
@@ -43069,9 +43086,8 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
|
||||
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
||||
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
||||
CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
||||
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
||||
CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
|
||||
CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
|
||||
CheckMode3[CheckMode3["RestBindingElement"] = 32] = "RestBindingElement";
|
||||
CheckMode3[CheckMode3["TypeOnly"] = 64] = "TypeOnly";
|
||||
return CheckMode3;
|
||||
})(CheckMode || {});
|
||||
var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
||||
@@ -43558,7 +43574,7 @@ function createTypeChecker(host) {
|
||||
candidates,
|
||||
/*argumentCount*/
|
||||
void 0,
|
||||
32 /* IsForStringLiteralArgumentCompletions */
|
||||
0 /* Normal */
|
||||
));
|
||||
for (const candidate of candidates) {
|
||||
candidatesSet.add(candidate);
|
||||
@@ -51593,7 +51609,7 @@ function createTypeChecker(host) {
|
||||
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
||||
}
|
||||
function getTypeForBindingElement(declaration) {
|
||||
const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
||||
const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
||||
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
||||
return parentType && getBindingElementTypeFromParentType(
|
||||
declaration,
|
||||
@@ -63760,7 +63776,7 @@ function createTypeChecker(host) {
|
||||
if (!couldContainTypeVariables(target)) {
|
||||
return;
|
||||
}
|
||||
if (source === wildcardType) {
|
||||
if (source === wildcardType || source === blockedStringType) {
|
||||
const savePropagationType = propagationType;
|
||||
propagationType = source;
|
||||
inferFromTypes(target, target);
|
||||
@@ -63817,6 +63833,10 @@ function createTypeChecker(host) {
|
||||
return;
|
||||
}
|
||||
if (!inference.isFixed) {
|
||||
const candidate = propagationType || source;
|
||||
if (candidate === blockedStringType) {
|
||||
return;
|
||||
}
|
||||
if (inference.priority === void 0 || priority < inference.priority) {
|
||||
inference.candidates = void 0;
|
||||
inference.contraCandidates = void 0;
|
||||
@@ -63824,7 +63844,6 @@ function createTypeChecker(host) {
|
||||
inference.priority = priority;
|
||||
}
|
||||
if (priority === inference.priority) {
|
||||
const candidate = propagationType || source;
|
||||
if (contravariant && !bivariant) {
|
||||
if (!contains(inference.contraCandidates, candidate)) {
|
||||
inference.contraCandidates = append(inference.contraCandidates, candidate);
|
||||
@@ -64396,7 +64415,7 @@ function createTypeChecker(host) {
|
||||
const constraint = getConstraintOfTypeParameter(inference.typeParameter);
|
||||
if (constraint) {
|
||||
const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
|
||||
if (!inferredType || inferredType === blockedStringType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
|
||||
if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
|
||||
inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
|
||||
}
|
||||
}
|
||||
@@ -65247,7 +65266,10 @@ function createTypeChecker(host) {
|
||||
let signature = links.effectsSignature;
|
||||
if (signature === void 0) {
|
||||
let funcType;
|
||||
if (node.parent.kind === 244 /* ExpressionStatement */) {
|
||||
if (isBinaryExpression(node)) {
|
||||
const rightType = checkNonNullExpression(node.right);
|
||||
funcType = getSymbolHasInstanceMethodOfObjectType(rightType);
|
||||
} else if (node.parent.kind === 244 /* ExpressionStatement */) {
|
||||
funcType = getTypeOfDottedName(
|
||||
node.expression,
|
||||
/*diagnostic*/
|
||||
@@ -66271,7 +66293,22 @@ function createTypeChecker(host) {
|
||||
}
|
||||
return type;
|
||||
}
|
||||
const rightType = getTypeOfExpression(expr.right);
|
||||
const right = expr.right;
|
||||
const rightType = getTypeOfExpression(right);
|
||||
if (!isTypeDerivedFrom(rightType, globalObjectType)) {
|
||||
return type;
|
||||
}
|
||||
const signature = getEffectsSignature(expr);
|
||||
const predicate = signature && getTypePredicateOfSignature(signature);
|
||||
if (predicate && predicate.kind === 1 /* Identifier */ && predicate.parameterIndex === 0) {
|
||||
return getNarrowedType(
|
||||
type,
|
||||
predicate.type,
|
||||
assumeTrue,
|
||||
/*checkDerived*/
|
||||
true
|
||||
);
|
||||
}
|
||||
if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
|
||||
return type;
|
||||
}
|
||||
@@ -66523,7 +66560,7 @@ function createTypeChecker(host) {
|
||||
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
||||
}
|
||||
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
||||
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 /* RestBindingElement */ ? getContextualType(node, 8 /* SkipBindingPatterns */) : getContextualType(
|
||||
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 32 /* RestBindingElement */ ? getContextualType(node, 8 /* SkipBindingPatterns */) : getContextualType(
|
||||
node,
|
||||
/*contextFlags*/
|
||||
void 0
|
||||
@@ -67283,7 +67320,7 @@ function createTypeChecker(host) {
|
||||
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
||||
const parent = declaration.parent.parent;
|
||||
const name = declaration.propertyName || declaration.name;
|
||||
const parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 208 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
||||
const parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 208 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
|
||||
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
||||
return void 0;
|
||||
if (parent.name.kind === 207 /* ArrayBindingPattern */) {
|
||||
@@ -69266,7 +69303,7 @@ function createTypeChecker(host) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassFieldAndNotAutoAccessor))) {
|
||||
if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassInstanceProperty))) {
|
||||
if (errorNode) {
|
||||
error(errorNode, Diagnostics.Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super, symbolToString(prop));
|
||||
}
|
||||
@@ -70129,7 +70166,9 @@ function createTypeChecker(host) {
|
||||
checkExpression(node.template);
|
||||
} else if (isJsxOpeningLikeElement(node)) {
|
||||
checkExpression(node.attributes);
|
||||
} else if (node.kind !== 170 /* Decorator */) {
|
||||
} else if (isBinaryExpression(node)) {
|
||||
checkExpression(node.left);
|
||||
} else if (isCallOrNewExpression(node)) {
|
||||
forEach(node.arguments, (argument) => {
|
||||
checkExpression(argument);
|
||||
});
|
||||
@@ -70202,6 +70241,8 @@ function createTypeChecker(host) {
|
||||
}
|
||||
} else if (node.kind === 170 /* Decorator */) {
|
||||
argCount = getDecoratorArgumentCount(node, signature);
|
||||
} else if (node.kind === 226 /* BinaryExpression */) {
|
||||
argCount = 1;
|
||||
} else if (isJsxOpeningLikeElement(node)) {
|
||||
callIsIncomplete = node.attributes.end === node.end;
|
||||
if (callIsIncomplete) {
|
||||
@@ -70301,13 +70342,13 @@ function createTypeChecker(host) {
|
||||
return voidType;
|
||||
}
|
||||
const thisArgumentType = checkExpression(thisArgumentNode);
|
||||
return isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : thisArgumentType;
|
||||
return isRightSideOfInstanceofExpression(thisArgumentNode) ? thisArgumentType : isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : thisArgumentType;
|
||||
}
|
||||
function inferTypeArguments(node, signature, args, checkMode, context) {
|
||||
if (isJsxOpeningLikeElement(node)) {
|
||||
return inferJsxTypeArguments(node, signature, checkMode, context);
|
||||
}
|
||||
if (node.kind !== 170 /* Decorator */) {
|
||||
if (node.kind !== 170 /* Decorator */ && node.kind !== 226 /* BinaryExpression */) {
|
||||
const skipBindingPatterns = every(signature.typeParameters, (p) => !!getDefaultFromTypeParameter(p));
|
||||
const contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
||||
if (contextualType) {
|
||||
@@ -70344,7 +70385,7 @@ function createTypeChecker(host) {
|
||||
}
|
||||
for (let i = 0; i < argCount; i++) {
|
||||
const arg = args[i];
|
||||
if (arg.kind !== 232 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
||||
if (arg.kind !== 232 /* OmittedExpression */) {
|
||||
const paramType = getTypeAtPosition(signature, i);
|
||||
if (couldContainTypeVariables(paramType)) {
|
||||
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
||||
@@ -70636,6 +70677,9 @@ function createTypeChecker(host) {
|
||||
}
|
||||
}
|
||||
function getThisArgumentOfCall(node) {
|
||||
if (node.kind === 226 /* BinaryExpression */) {
|
||||
return node.right;
|
||||
}
|
||||
const expression = node.kind === 213 /* CallExpression */ ? node.expression : node.kind === 215 /* TaggedTemplateExpression */ ? node.tag : node.kind === 170 /* Decorator */ && !legacyDecorators ? node.expression : void 0;
|
||||
if (expression) {
|
||||
const callee = skipOuterExpressions(expression);
|
||||
@@ -70664,6 +70708,9 @@ function createTypeChecker(host) {
|
||||
if (node.kind === 170 /* Decorator */) {
|
||||
return getEffectiveDecoratorArguments(node);
|
||||
}
|
||||
if (node.kind === 226 /* BinaryExpression */) {
|
||||
return [node.left];
|
||||
}
|
||||
if (isJsxOpeningLikeElement(node)) {
|
||||
return node.attributes.properties.length > 0 || isJsxOpeningElement(node) && node.parent.children.length > 0 ? [node.attributes] : emptyArray;
|
||||
}
|
||||
@@ -70933,9 +70980,10 @@ function createTypeChecker(host) {
|
||||
const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
|
||||
const isDecorator2 = node.kind === 170 /* Decorator */;
|
||||
const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
|
||||
const isInstanceof = node.kind === 226 /* BinaryExpression */;
|
||||
const reportErrors2 = !isInferencePartiallyBlocked && !candidatesOutArray;
|
||||
let typeArguments;
|
||||
if (!isDecorator2 && !isSuperCall(node)) {
|
||||
if (!isDecorator2 && !isInstanceof && !isSuperCall(node)) {
|
||||
typeArguments = node.typeArguments;
|
||||
if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 108 /* SuperKeyword */) {
|
||||
forEach(typeArguments, checkSourceElement);
|
||||
@@ -70947,7 +70995,6 @@ function createTypeChecker(host) {
|
||||
const args = getEffectiveCallArguments(node);
|
||||
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
||||
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
||||
argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
||||
let candidatesForArgumentError;
|
||||
let candidateForArgumentArityError;
|
||||
let candidateForTypeArgumentError;
|
||||
@@ -70965,6 +71012,9 @@ function createTypeChecker(host) {
|
||||
result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
||||
getNodeLinks(node).resolvedSignature = result;
|
||||
if (reportErrors2) {
|
||||
if (!headMessage && isInstanceof) {
|
||||
headMessage = Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method;
|
||||
}
|
||||
if (candidatesForArgumentError) {
|
||||
if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
|
||||
const last2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
|
||||
@@ -71751,6 +71801,30 @@ function createTypeChecker(host) {
|
||||
}
|
||||
return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
|
||||
}
|
||||
function resolveInstanceofExpression(node, candidatesOutArray, checkMode) {
|
||||
const rightType = checkExpression(node.right);
|
||||
if (!isTypeAny(rightType)) {
|
||||
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
|
||||
if (hasInstanceMethodType) {
|
||||
const apparentType = getApparentType(hasInstanceMethodType);
|
||||
if (isErrorType(apparentType)) {
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
const callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
|
||||
const constructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */);
|
||||
if (isUntypedFunctionCall(hasInstanceMethodType, apparentType, callSignatures.length, constructSignatures.length)) {
|
||||
return resolveUntypedCall(node);
|
||||
}
|
||||
if (callSignatures.length) {
|
||||
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
|
||||
}
|
||||
} else if (!(typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
|
||||
error(node.right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_type_assignable_to_the_Function_interface_type_or_an_object_type_with_a_Symbol_hasInstance_method);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
}
|
||||
return anySignature;
|
||||
}
|
||||
function isPotentiallyUncalledDecorator(decorator, signatures) {
|
||||
return signatures.length && every(signatures, (signature) => signature.minArgumentCount === 0 && !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature));
|
||||
}
|
||||
@@ -71767,6 +71841,8 @@ function createTypeChecker(host) {
|
||||
case 286 /* JsxOpeningElement */:
|
||||
case 285 /* JsxSelfClosingElement */:
|
||||
return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
|
||||
case 226 /* BinaryExpression */:
|
||||
return resolveInstanceofExpression(node, candidatesOutArray, checkMode);
|
||||
}
|
||||
Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
|
||||
}
|
||||
@@ -73725,16 +73801,35 @@ function createTypeChecker(host) {
|
||||
function isConstEnumSymbol(symbol) {
|
||||
return (symbol.flags & 128 /* ConstEnum */) !== 0;
|
||||
}
|
||||
function checkInstanceOfExpression(left, right, leftType, rightType) {
|
||||
function getSymbolHasInstanceMethodOfObjectType(type) {
|
||||
const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
|
||||
const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
|
||||
if (hasInstanceProperty) {
|
||||
const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
|
||||
if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
|
||||
return hasInstancePropertyType;
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkInstanceOfExpression(left, right, leftType, rightType, checkMode) {
|
||||
if (leftType === silentNeverType || rightType === silentNeverType) {
|
||||
return silentNeverType;
|
||||
}
|
||||
if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
|
||||
error(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
|
||||
error(right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
|
||||
Debug.assert(isInstanceOfExpression(left.parent));
|
||||
const signature = getResolvedSignature(
|
||||
left.parent,
|
||||
/*candidatesOutArray*/
|
||||
void 0,
|
||||
checkMode
|
||||
);
|
||||
if (signature === resolvingSignature) {
|
||||
return silentNeverType;
|
||||
}
|
||||
const returnType = getReturnTypeOfSignature(signature);
|
||||
checkTypeAssignableTo(returnType, booleanType, right, Diagnostics.An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression);
|
||||
return booleanType;
|
||||
}
|
||||
function hasEmptyObjectIntersection(type) {
|
||||
@@ -74272,7 +74367,7 @@ function createTypeChecker(host) {
|
||||
case 36 /* ExclamationEqualsToken */:
|
||||
case 37 /* EqualsEqualsEqualsToken */:
|
||||
case 38 /* ExclamationEqualsEqualsToken */:
|
||||
if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
|
||||
if (!(checkMode && checkMode & 64 /* TypeOnly */)) {
|
||||
if ((isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) && // only report for === and !== in JS, not == or !=
|
||||
(!isInJSFile(left) || (operator === 37 /* EqualsEqualsEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */))) {
|
||||
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
||||
@@ -74283,7 +74378,7 @@ function createTypeChecker(host) {
|
||||
}
|
||||
return booleanType;
|
||||
case 104 /* InstanceOfKeyword */:
|
||||
return checkInstanceOfExpression(left, right, leftType, rightType);
|
||||
return checkInstanceOfExpression(left, right, leftType, rightType, checkMode);
|
||||
case 103 /* InKeyword */:
|
||||
return checkInExpression(left, right, leftType, rightType);
|
||||
case 56 /* AmpersandAmpersandToken */:
|
||||
@@ -74920,7 +75015,7 @@ function createTypeChecker(host) {
|
||||
}
|
||||
}
|
||||
const startInvocationCount = flowInvocationCount;
|
||||
const type = checkExpression(node, 128 /* TypeOnly */);
|
||||
const type = checkExpression(node, 64 /* TypeOnly */);
|
||||
if (flowInvocationCount !== startInvocationCount) {
|
||||
const cache = flowTypeCache || (flowTypeCache = []);
|
||||
cache[getNodeId(node)] = type;
|
||||
@@ -77386,7 +77481,7 @@ function createTypeChecker(host) {
|
||||
checkComputedPropertyName(node.propertyName);
|
||||
}
|
||||
const parent = node.parent.parent;
|
||||
const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
||||
const parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
||||
const parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
||||
const name = node.propertyName || node.name;
|
||||
if (parentType && !isBindingPattern(name)) {
|
||||
@@ -79603,7 +79698,7 @@ function createTypeChecker(host) {
|
||||
}
|
||||
if (isConstantVariable(symbol)) {
|
||||
const declaration = symbol.valueDeclaration;
|
||||
if (declaration && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
|
||||
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
|
||||
return evaluate(declaration.initializer, declaration);
|
||||
}
|
||||
}
|
||||
@@ -80695,6 +80790,12 @@ function createTypeChecker(host) {
|
||||
case 234 /* AsExpression */:
|
||||
case 217 /* ParenthesizedExpression */:
|
||||
checkAssertionDeferred(node);
|
||||
break;
|
||||
case 226 /* BinaryExpression */:
|
||||
if (isInstanceOfExpression(node)) {
|
||||
resolveUntypedCall(node);
|
||||
}
|
||||
break;
|
||||
}
|
||||
currentNode = saveCurrentNode;
|
||||
(_b = tracing) == null ? void 0 : _b.pop();
|
||||
@@ -81311,6 +81412,13 @@ function createTypeChecker(host) {
|
||||
case 102 /* ImportKeyword */:
|
||||
case 105 /* NewKeyword */:
|
||||
return isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : void 0;
|
||||
case 104 /* InstanceOfKeyword */:
|
||||
if (isBinaryExpression(node.parent)) {
|
||||
const type = getTypeOfExpression(node.parent.right);
|
||||
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(type);
|
||||
return (hasInstanceMethodType == null ? void 0 : hasInstanceMethodType.symbol) ?? type.symbol;
|
||||
}
|
||||
return void 0;
|
||||
case 236 /* MetaProperty */:
|
||||
return checkExpression(node).symbol;
|
||||
case 295 /* JsxNamespacedName */:
|
||||
|
||||
+177
-995
File diff suppressed because it is too large
Load Diff
Vendored
+4
-1
@@ -5646,7 +5646,10 @@ declare namespace ts {
|
||||
readonly typeArguments?: NodeArray<TypeNode>;
|
||||
readonly template: TemplateLiteral;
|
||||
}
|
||||
type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement;
|
||||
interface InstanceofExpression extends BinaryExpression {
|
||||
readonly operatorToken: Token<SyntaxKind.InstanceOfKeyword>;
|
||||
}
|
||||
type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement | InstanceofExpression;
|
||||
interface AsExpression extends Expression {
|
||||
readonly kind: SyntaxKind.AsExpression;
|
||||
readonly expression: Expression;
|
||||
|
||||
+174
-998
File diff suppressed because it is too large
Load Diff
@@ -5579,7 +5579,7 @@ var Diagnostics = {
|
||||
An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
|
||||
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
|
||||
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
|
||||
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
|
||||
The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_type_assignable_to_the_Function_interface_type_or_an_object_type_with_a_Symbol_hasInstance_method: diag(2359, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_2359", "The right-hand side of an 'instanceof' expression must be either of type 'any', a class, function, or other type assignable to the 'Function' interface type, or an object type with a 'Symbol.hasInstance' method."),
|
||||
The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, 1 /* Error */, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
|
||||
The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, 1 /* Error */, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
|
||||
The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, 1 /* Error */, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."),
|
||||
@@ -6028,6 +6028,8 @@ var Diagnostics = {
|
||||
Import_attributes_cannot_be_used_with_type_only_imports_or_exports: diag(2857, 1 /* Error */, "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857", "Import attributes cannot be used with type-only imports or exports."),
|
||||
Import_attribute_values_must_be_string_literal_expressions: diag(2858, 1 /* Error */, "Import_attribute_values_must_be_string_literal_expressions_2858", "Import attribute values must be string literal expressions."),
|
||||
Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."),
|
||||
The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method: diag(2860, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2860", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."),
|
||||
An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression: diag(2861, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2861", "An object's '[Symbol.hasInstance]' method must return a boolean value for it to be used on the right-hand side of an 'instanceof' expression."),
|
||||
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
||||
@@ -29182,9 +29184,8 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
|
||||
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
||||
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
||||
CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
||||
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
||||
CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
|
||||
CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
|
||||
CheckMode3[CheckMode3["RestBindingElement"] = 32] = "RestBindingElement";
|
||||
CheckMode3[CheckMode3["TypeOnly"] = 64] = "TypeOnly";
|
||||
return CheckMode3;
|
||||
})(CheckMode || {});
|
||||
var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
||||
|
||||
Reference in New Issue
Block a user