@typescript-deploys/pr-build 5.2.0-pr-54935-17 → 5.2.0-pr-55052-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +93 -61
- package/lib/tsserver.js +90 -61
- package/lib/tsserverlibrary.d.ts +1 -1
- package/lib/tsserverlibrary.js +90 -61
- package/lib/typescript.d.ts +1 -1
- package/lib/typescript.js +90 -61
- package/lib/typingsInstaller.js +4 -0
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -6668,6 +6668,9 @@ var Diagnostics = {
|
|
|
6668
6668
|
await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(2852, 1 /* Error */, "await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_2852", "'await using' statements are only allowed within async functions and at the top levels of modules."),
|
|
6669
6669
|
await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(2853, 1 /* Error */, "await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_th_2853", "'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
6670
6670
|
Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(2854, 1 /* Error */, "Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_sys_2854", "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
6671
|
+
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(2855, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2855", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."),
|
|
6672
|
+
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(2856, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2856", "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."),
|
|
6673
|
+
The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Symbol_hasInstance_method_or_a_type_assignable_to_the_Function_interface_type: diag(2857, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Sym_2857", "The right-hand side of an 'instanceof' expression must be either of type 'any', an object type with a '[Symbol.hasInstance]()' method, or a type assignable to the 'Function' interface type."),
|
|
6671
6674
|
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}'."),
|
|
6672
6675
|
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}'."),
|
|
6673
6676
|
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}'."),
|
|
@@ -10991,6 +10994,7 @@ function isLeftHandSideExpressionKind(kind) {
|
|
|
10991
10994
|
case 236 /* MetaProperty */:
|
|
10992
10995
|
case 102 /* ImportKeyword */:
|
|
10993
10996
|
case 282 /* MissingDeclaration */:
|
|
10997
|
+
case 237 /* SyntheticExpression */:
|
|
10994
10998
|
return true;
|
|
10995
10999
|
default:
|
|
10996
11000
|
return false;
|
|
@@ -24271,6 +24275,9 @@ function isNonNullExpression(node) {
|
|
|
24271
24275
|
function isMetaProperty(node) {
|
|
24272
24276
|
return node.kind === 236 /* MetaProperty */;
|
|
24273
24277
|
}
|
|
24278
|
+
function isSyntheticExpression(node) {
|
|
24279
|
+
return node.kind === 237 /* SyntheticExpression */;
|
|
24280
|
+
}
|
|
24274
24281
|
function isPartiallyEmittedExpression(node) {
|
|
24275
24282
|
return node.kind === 360 /* PartiallyEmittedExpression */;
|
|
24276
24283
|
}
|
|
@@ -43863,6 +43870,7 @@ function createTypeChecker(host) {
|
|
|
43863
43870
|
var potentialReflectCollisions = [];
|
|
43864
43871
|
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
43865
43872
|
var awaitedTypeStack = [];
|
|
43873
|
+
var hasGlobalSymbolHasInstanceProperty;
|
|
43866
43874
|
var diagnostics = createDiagnosticCollection();
|
|
43867
43875
|
var suggestionDiagnostics = createDiagnosticCollection();
|
|
43868
43876
|
var typeofType = createTypeofType();
|
|
@@ -48184,7 +48192,7 @@ function createTypeChecker(host) {
|
|
|
48184
48192
|
return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */));
|
|
48185
48193
|
}
|
|
48186
48194
|
function addPropertyToElementList(propertySymbol, context, typeElements) {
|
|
48187
|
-
var _a
|
|
48195
|
+
var _a;
|
|
48188
48196
|
const propertyIsReverseMapped = !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */);
|
|
48189
48197
|
const propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol);
|
|
48190
48198
|
const saveEnclosingDeclaration = context.enclosingDeclaration;
|
|
@@ -48234,57 +48242,17 @@ function createTypeChecker(host) {
|
|
|
48234
48242
|
context.reverseMappedStack.pop();
|
|
48235
48243
|
}
|
|
48236
48244
|
}
|
|
48237
|
-
|
|
48238
|
-
|
|
48239
|
-
|
|
48240
|
-
const getAccessorSignature = factory.createGetAccessorDeclaration(
|
|
48241
|
-
/*modifiers*/
|
|
48242
|
-
void 0,
|
|
48243
|
-
propertyName,
|
|
48244
|
-
[],
|
|
48245
|
-
propertyTypeNode,
|
|
48246
|
-
/*body*/
|
|
48247
|
-
void 0
|
|
48248
|
-
);
|
|
48249
|
-
setCommentRange(getAccessorSignature, getAccessorDecl);
|
|
48250
|
-
typeElements.push(getAccessorSignature);
|
|
48251
|
-
}
|
|
48252
|
-
if (propertySymbol.flags & 65536 /* SetAccessor */) {
|
|
48253
|
-
const setAccessorDecl = find(propertySymbol.declarations, (decl) => decl.kind === 178 /* SetAccessor */);
|
|
48254
|
-
const parameterName = ((_b = setAccessorDecl == null ? void 0 : setAccessorDecl.parameters) == null ? void 0 : _b.length) > 0 ? setAccessorDecl.parameters[0].name : "arg";
|
|
48255
|
-
const setAccessorSignature = factory.createSetAccessorDeclaration(
|
|
48256
|
-
/*modifiers*/
|
|
48257
|
-
void 0,
|
|
48258
|
-
propertyName,
|
|
48259
|
-
[factory.createParameterDeclaration(
|
|
48260
|
-
/*modifiers*/
|
|
48261
|
-
void 0,
|
|
48262
|
-
/*dotDotDotToken*/
|
|
48263
|
-
void 0,
|
|
48264
|
-
parameterName,
|
|
48265
|
-
/*questionToken*/
|
|
48266
|
-
void 0,
|
|
48267
|
-
propertyTypeNode
|
|
48268
|
-
)],
|
|
48269
|
-
/*body*/
|
|
48270
|
-
void 0
|
|
48271
|
-
);
|
|
48272
|
-
setCommentRange(setAccessorSignature, setAccessorDecl);
|
|
48273
|
-
typeElements.push(setAccessorSignature);
|
|
48274
|
-
}
|
|
48275
|
-
} else {
|
|
48276
|
-
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
|
|
48277
|
-
if (modifiers) {
|
|
48278
|
-
context.approximateLength += 9;
|
|
48279
|
-
}
|
|
48280
|
-
const propertySignature = factory.createPropertySignature(
|
|
48281
|
-
modifiers,
|
|
48282
|
-
propertyName,
|
|
48283
|
-
optionalToken,
|
|
48284
|
-
propertyTypeNode
|
|
48285
|
-
);
|
|
48286
|
-
typeElements.push(preserveCommentsOn(propertySignature));
|
|
48245
|
+
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
|
|
48246
|
+
if (modifiers) {
|
|
48247
|
+
context.approximateLength += 9;
|
|
48287
48248
|
}
|
|
48249
|
+
const propertySignature = factory.createPropertySignature(
|
|
48250
|
+
modifiers,
|
|
48251
|
+
propertyName,
|
|
48252
|
+
optionalToken,
|
|
48253
|
+
propertyTypeNode
|
|
48254
|
+
);
|
|
48255
|
+
typeElements.push(preserveCommentsOn(propertySignature));
|
|
48288
48256
|
function preserveCommentsOn(node) {
|
|
48289
48257
|
var _a2;
|
|
48290
48258
|
if (some(propertySymbol.declarations, (d) => d.kind === 355 /* JSDocPropertyTag */)) {
|
|
@@ -65945,6 +65913,15 @@ function createTypeChecker(host) {
|
|
|
65945
65913
|
return type;
|
|
65946
65914
|
}
|
|
65947
65915
|
const rightType = getTypeOfExpression(expr.right);
|
|
65916
|
+
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
|
|
65917
|
+
if (hasInstanceMethodType) {
|
|
65918
|
+
const syntheticCall = createSyntheticHasInstanceMethodCall(left, expr.right, type, hasInstanceMethodType);
|
|
65919
|
+
const signature = getEffectsSignature(syntheticCall);
|
|
65920
|
+
const predicate = signature && getTypePredicateOfSignature(signature);
|
|
65921
|
+
if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
|
|
65922
|
+
return narrowTypeByTypePredicate(type, predicate, syntheticCall, assumeTrue);
|
|
65923
|
+
}
|
|
65924
|
+
}
|
|
65948
65925
|
if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
|
|
65949
65926
|
return type;
|
|
65950
65927
|
}
|
|
@@ -66024,8 +66001,12 @@ function createTypeChecker(host) {
|
|
|
66024
66001
|
}
|
|
66025
66002
|
function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
|
|
66026
66003
|
if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
|
|
66027
|
-
|
|
66004
|
+
let predicateArgument = getTypePredicateArgument(predicate, callExpression);
|
|
66028
66005
|
if (predicateArgument) {
|
|
66006
|
+
if (isSyntheticExpression(predicateArgument) && predicate.parameterIndex === 0 && isSyntheticHasInstanceMethodCall(callExpression)) {
|
|
66007
|
+
Debug.assertNode(predicateArgument.parent, isExpression);
|
|
66008
|
+
predicateArgument = predicateArgument.parent;
|
|
66009
|
+
}
|
|
66029
66010
|
if (isMatchingReference(reference, predicateArgument)) {
|
|
66030
66011
|
return getNarrowedType(
|
|
66031
66012
|
type,
|
|
@@ -70602,7 +70583,7 @@ function createTypeChecker(host) {
|
|
|
70602
70583
|
}
|
|
70603
70584
|
return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
|
|
70604
70585
|
}
|
|
70605
|
-
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags,
|
|
70586
|
+
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessageCallback) {
|
|
70606
70587
|
const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
|
|
70607
70588
|
const isDecorator2 = node.kind === 170 /* Decorator */;
|
|
70608
70589
|
const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
|
|
@@ -70645,6 +70626,7 @@ function createTypeChecker(host) {
|
|
|
70645
70626
|
chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error);
|
|
70646
70627
|
chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call);
|
|
70647
70628
|
}
|
|
70629
|
+
const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
|
|
70648
70630
|
if (headMessage) {
|
|
70649
70631
|
chain = chainDiagnosticMessages(chain, headMessage);
|
|
70650
70632
|
}
|
|
@@ -70712,6 +70694,7 @@ function createTypeChecker(host) {
|
|
|
70712
70694
|
map(diags, createDiagnosticMessageChainFromDiagnostic),
|
|
70713
70695
|
Diagnostics.No_overload_matches_this_call
|
|
70714
70696
|
);
|
|
70697
|
+
const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
|
|
70715
70698
|
if (headMessage) {
|
|
70716
70699
|
chain = chainDiagnosticMessages(chain, headMessage);
|
|
70717
70700
|
}
|
|
@@ -70727,21 +70710,21 @@ function createTypeChecker(host) {
|
|
|
70727
70710
|
diagnostics.add(diag2);
|
|
70728
70711
|
}
|
|
70729
70712
|
} else if (candidateForArgumentArityError) {
|
|
70730
|
-
diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args,
|
|
70713
|
+
diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
70731
70714
|
} else if (candidateForTypeArgumentError) {
|
|
70732
70715
|
checkTypeArguments(
|
|
70733
70716
|
candidateForTypeArgumentError,
|
|
70734
70717
|
node.typeArguments,
|
|
70735
70718
|
/*reportErrors*/
|
|
70736
70719
|
true,
|
|
70737
|
-
|
|
70720
|
+
headMessageCallback == null ? void 0 : headMessageCallback()
|
|
70738
70721
|
);
|
|
70739
70722
|
} else {
|
|
70740
70723
|
const signaturesWithCorrectTypeArgumentArity = filter(signatures, (s) => hasCorrectTypeArgumentArity(s, typeArguments));
|
|
70741
70724
|
if (signaturesWithCorrectTypeArgumentArity.length === 0) {
|
|
70742
|
-
diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments,
|
|
70725
|
+
diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
70743
70726
|
} else {
|
|
70744
|
-
diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args,
|
|
70727
|
+
diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
70745
70728
|
}
|
|
70746
70729
|
}
|
|
70747
70730
|
}
|
|
@@ -71049,7 +71032,7 @@ function createTypeChecker(host) {
|
|
|
71049
71032
|
error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
|
|
71050
71033
|
return resolveErrorCall(node);
|
|
71051
71034
|
}
|
|
71052
|
-
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
71035
|
+
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags, () => isSyntheticHasInstanceMethodCall(node) ? 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 : void 0);
|
|
71053
71036
|
}
|
|
71054
71037
|
function isGenericFunctionReturningFunction(signature) {
|
|
71055
71038
|
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
|
|
@@ -71346,7 +71329,7 @@ function createTypeChecker(host) {
|
|
|
71346
71329
|
invocationErrorRecovery(apparentType, 0 /* Call */, diag2);
|
|
71347
71330
|
return resolveErrorCall(node);
|
|
71348
71331
|
}
|
|
71349
|
-
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
|
|
71332
|
+
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, () => headMessage);
|
|
71350
71333
|
}
|
|
71351
71334
|
function createSignatureForJSXIntrinsic(node, result) {
|
|
71352
71335
|
const namespace = getJsxNamespaceAt(node);
|
|
@@ -73379,6 +73362,32 @@ function createTypeChecker(host) {
|
|
|
73379
73362
|
function isConstEnumSymbol(symbol) {
|
|
73380
73363
|
return (symbol.flags & 128 /* ConstEnum */) !== 0;
|
|
73381
73364
|
}
|
|
73365
|
+
function getSymbolHasInstanceMethodOfObjectType(type) {
|
|
73366
|
+
const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
|
|
73367
|
+
const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
|
|
73368
|
+
if (hasInstanceProperty) {
|
|
73369
|
+
const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
|
|
73370
|
+
if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
|
|
73371
|
+
return hasInstancePropertyType;
|
|
73372
|
+
}
|
|
73373
|
+
}
|
|
73374
|
+
}
|
|
73375
|
+
function createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType) {
|
|
73376
|
+
const syntheticExpression = createSyntheticExpression(right, hasInstanceMethodType);
|
|
73377
|
+
const syntheticArgument = createSyntheticExpression(left, leftType);
|
|
73378
|
+
const syntheticCall = parseNodeFactory.createCallExpression(
|
|
73379
|
+
syntheticExpression,
|
|
73380
|
+
/*typeArguments*/
|
|
73381
|
+
void 0,
|
|
73382
|
+
[syntheticArgument]
|
|
73383
|
+
);
|
|
73384
|
+
setParent(syntheticCall, left.parent);
|
|
73385
|
+
setTextRange(syntheticCall, left.parent);
|
|
73386
|
+
return syntheticCall;
|
|
73387
|
+
}
|
|
73388
|
+
function isSyntheticHasInstanceMethodCall(node) {
|
|
73389
|
+
return isSyntheticExpression(node.expression) && node.arguments.length === 1 && isSyntheticExpression(node.arguments[0]) && isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 104 /* InstanceOfKeyword */ && node.parent.right === node.expression.parent && node.parent.left === node.arguments[0].parent;
|
|
73390
|
+
}
|
|
73382
73391
|
function checkInstanceOfExpression(left, right, leftType, rightType) {
|
|
73383
73392
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
73384
73393
|
return silentNeverType;
|
|
@@ -73386,8 +73395,31 @@ function createTypeChecker(host) {
|
|
|
73386
73395
|
if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
|
|
73387
73396
|
error(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
|
73388
73397
|
}
|
|
73389
|
-
if (!
|
|
73390
|
-
|
|
73398
|
+
if (!isTypeAny(rightType)) {
|
|
73399
|
+
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
|
|
73400
|
+
if (hasInstanceMethodType) {
|
|
73401
|
+
const cache = hasInstanceMethodType;
|
|
73402
|
+
if (cache.hasSimpleUnrestrictedSingleCallSignature === void 0) {
|
|
73403
|
+
const signature = getSingleCallSignature(hasInstanceMethodType);
|
|
73404
|
+
cache.hasSimpleUnrestrictedSingleCallSignature = !!signature && signature.parameters.length === 1 && !!(getTypeOfSymbol(signature.parameters[0]).flags & 3 /* AnyOrUnknown */) && !!signature.resolvedReturnType && !!(signature.resolvedReturnType.flags & 16 /* Boolean */);
|
|
73405
|
+
}
|
|
73406
|
+
if (!cache.hasSimpleUnrestrictedSingleCallSignature) {
|
|
73407
|
+
const syntheticCall = createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType);
|
|
73408
|
+
const returnType = getReturnTypeOfSignature(getResolvedSignature(syntheticCall));
|
|
73409
|
+
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);
|
|
73410
|
+
}
|
|
73411
|
+
}
|
|
73412
|
+
if (!(hasInstanceMethodType || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
|
|
73413
|
+
if (hasGlobalSymbolHasInstanceProperty === void 0) {
|
|
73414
|
+
const globalESSymbolConstructorSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
73415
|
+
/*reportErrors*/
|
|
73416
|
+
false
|
|
73417
|
+
);
|
|
73418
|
+
hasGlobalSymbolHasInstanceProperty = !!globalESSymbolConstructorSymbol && getMembersOfSymbol(globalESSymbolConstructorSymbol).has("hasInstance");
|
|
73419
|
+
}
|
|
73420
|
+
const message = hasGlobalSymbolHasInstanceProperty ? Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Symbol_hasInstance_method_or_a_type_assignable_to_the_Function_interface_type : Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type;
|
|
73421
|
+
error(right, message);
|
|
73422
|
+
}
|
|
73391
73423
|
}
|
|
73392
73424
|
return booleanType;
|
|
73393
73425
|
}
|
package/lib/tsserver.js
CHANGED
|
@@ -10189,6 +10189,9 @@ var Diagnostics = {
|
|
|
10189
10189
|
await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(2852, 1 /* Error */, "await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_2852", "'await using' statements are only allowed within async functions and at the top levels of modules."),
|
|
10190
10190
|
await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(2853, 1 /* Error */, "await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_th_2853", "'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
10191
10191
|
Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(2854, 1 /* Error */, "Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_sys_2854", "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
10192
|
+
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(2855, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2855", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."),
|
|
10193
|
+
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(2856, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2856", "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."),
|
|
10194
|
+
The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Symbol_hasInstance_method_or_a_type_assignable_to_the_Function_interface_type: diag(2857, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Sym_2857", "The right-hand side of an 'instanceof' expression must be either of type 'any', an object type with a '[Symbol.hasInstance]()' method, or a type assignable to the 'Function' interface type."),
|
|
10192
10195
|
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}'."),
|
|
10193
10196
|
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}'."),
|
|
10194
10197
|
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}'."),
|
|
@@ -14662,6 +14665,7 @@ function isLeftHandSideExpressionKind(kind) {
|
|
|
14662
14665
|
case 236 /* MetaProperty */:
|
|
14663
14666
|
case 102 /* ImportKeyword */:
|
|
14664
14667
|
case 282 /* MissingDeclaration */:
|
|
14668
|
+
case 237 /* SyntheticExpression */:
|
|
14665
14669
|
return true;
|
|
14666
14670
|
default:
|
|
14667
14671
|
return false;
|
|
@@ -48570,6 +48574,7 @@ function createTypeChecker(host) {
|
|
|
48570
48574
|
var potentialReflectCollisions = [];
|
|
48571
48575
|
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
48572
48576
|
var awaitedTypeStack = [];
|
|
48577
|
+
var hasGlobalSymbolHasInstanceProperty;
|
|
48573
48578
|
var diagnostics = createDiagnosticCollection();
|
|
48574
48579
|
var suggestionDiagnostics = createDiagnosticCollection();
|
|
48575
48580
|
var typeofType = createTypeofType();
|
|
@@ -52891,7 +52896,7 @@ function createTypeChecker(host) {
|
|
|
52891
52896
|
return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */));
|
|
52892
52897
|
}
|
|
52893
52898
|
function addPropertyToElementList(propertySymbol, context, typeElements) {
|
|
52894
|
-
var _a
|
|
52899
|
+
var _a;
|
|
52895
52900
|
const propertyIsReverseMapped = !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */);
|
|
52896
52901
|
const propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol);
|
|
52897
52902
|
const saveEnclosingDeclaration = context.enclosingDeclaration;
|
|
@@ -52941,57 +52946,17 @@ function createTypeChecker(host) {
|
|
|
52941
52946
|
context.reverseMappedStack.pop();
|
|
52942
52947
|
}
|
|
52943
52948
|
}
|
|
52944
|
-
|
|
52945
|
-
|
|
52946
|
-
|
|
52947
|
-
const getAccessorSignature = factory.createGetAccessorDeclaration(
|
|
52948
|
-
/*modifiers*/
|
|
52949
|
-
void 0,
|
|
52950
|
-
propertyName,
|
|
52951
|
-
[],
|
|
52952
|
-
propertyTypeNode,
|
|
52953
|
-
/*body*/
|
|
52954
|
-
void 0
|
|
52955
|
-
);
|
|
52956
|
-
setCommentRange(getAccessorSignature, getAccessorDecl);
|
|
52957
|
-
typeElements.push(getAccessorSignature);
|
|
52958
|
-
}
|
|
52959
|
-
if (propertySymbol.flags & 65536 /* SetAccessor */) {
|
|
52960
|
-
const setAccessorDecl = find(propertySymbol.declarations, (decl) => decl.kind === 178 /* SetAccessor */);
|
|
52961
|
-
const parameterName = ((_b = setAccessorDecl == null ? void 0 : setAccessorDecl.parameters) == null ? void 0 : _b.length) > 0 ? setAccessorDecl.parameters[0].name : "arg";
|
|
52962
|
-
const setAccessorSignature = factory.createSetAccessorDeclaration(
|
|
52963
|
-
/*modifiers*/
|
|
52964
|
-
void 0,
|
|
52965
|
-
propertyName,
|
|
52966
|
-
[factory.createParameterDeclaration(
|
|
52967
|
-
/*modifiers*/
|
|
52968
|
-
void 0,
|
|
52969
|
-
/*dotDotDotToken*/
|
|
52970
|
-
void 0,
|
|
52971
|
-
parameterName,
|
|
52972
|
-
/*questionToken*/
|
|
52973
|
-
void 0,
|
|
52974
|
-
propertyTypeNode
|
|
52975
|
-
)],
|
|
52976
|
-
/*body*/
|
|
52977
|
-
void 0
|
|
52978
|
-
);
|
|
52979
|
-
setCommentRange(setAccessorSignature, setAccessorDecl);
|
|
52980
|
-
typeElements.push(setAccessorSignature);
|
|
52981
|
-
}
|
|
52982
|
-
} else {
|
|
52983
|
-
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
|
|
52984
|
-
if (modifiers) {
|
|
52985
|
-
context.approximateLength += 9;
|
|
52986
|
-
}
|
|
52987
|
-
const propertySignature = factory.createPropertySignature(
|
|
52988
|
-
modifiers,
|
|
52989
|
-
propertyName,
|
|
52990
|
-
optionalToken,
|
|
52991
|
-
propertyTypeNode
|
|
52992
|
-
);
|
|
52993
|
-
typeElements.push(preserveCommentsOn(propertySignature));
|
|
52949
|
+
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
|
|
52950
|
+
if (modifiers) {
|
|
52951
|
+
context.approximateLength += 9;
|
|
52994
52952
|
}
|
|
52953
|
+
const propertySignature = factory.createPropertySignature(
|
|
52954
|
+
modifiers,
|
|
52955
|
+
propertyName,
|
|
52956
|
+
optionalToken,
|
|
52957
|
+
propertyTypeNode
|
|
52958
|
+
);
|
|
52959
|
+
typeElements.push(preserveCommentsOn(propertySignature));
|
|
52995
52960
|
function preserveCommentsOn(node) {
|
|
52996
52961
|
var _a2;
|
|
52997
52962
|
if (some(propertySymbol.declarations, (d) => d.kind === 355 /* JSDocPropertyTag */)) {
|
|
@@ -70652,6 +70617,15 @@ function createTypeChecker(host) {
|
|
|
70652
70617
|
return type;
|
|
70653
70618
|
}
|
|
70654
70619
|
const rightType = getTypeOfExpression(expr.right);
|
|
70620
|
+
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
|
|
70621
|
+
if (hasInstanceMethodType) {
|
|
70622
|
+
const syntheticCall = createSyntheticHasInstanceMethodCall(left, expr.right, type, hasInstanceMethodType);
|
|
70623
|
+
const signature = getEffectsSignature(syntheticCall);
|
|
70624
|
+
const predicate = signature && getTypePredicateOfSignature(signature);
|
|
70625
|
+
if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
|
|
70626
|
+
return narrowTypeByTypePredicate(type, predicate, syntheticCall, assumeTrue);
|
|
70627
|
+
}
|
|
70628
|
+
}
|
|
70655
70629
|
if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
|
|
70656
70630
|
return type;
|
|
70657
70631
|
}
|
|
@@ -70731,8 +70705,12 @@ function createTypeChecker(host) {
|
|
|
70731
70705
|
}
|
|
70732
70706
|
function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
|
|
70733
70707
|
if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
|
|
70734
|
-
|
|
70708
|
+
let predicateArgument = getTypePredicateArgument(predicate, callExpression);
|
|
70735
70709
|
if (predicateArgument) {
|
|
70710
|
+
if (isSyntheticExpression(predicateArgument) && predicate.parameterIndex === 0 && isSyntheticHasInstanceMethodCall(callExpression)) {
|
|
70711
|
+
Debug.assertNode(predicateArgument.parent, isExpression);
|
|
70712
|
+
predicateArgument = predicateArgument.parent;
|
|
70713
|
+
}
|
|
70736
70714
|
if (isMatchingReference(reference, predicateArgument)) {
|
|
70737
70715
|
return getNarrowedType(
|
|
70738
70716
|
type,
|
|
@@ -75309,7 +75287,7 @@ function createTypeChecker(host) {
|
|
|
75309
75287
|
}
|
|
75310
75288
|
return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
|
|
75311
75289
|
}
|
|
75312
|
-
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags,
|
|
75290
|
+
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessageCallback) {
|
|
75313
75291
|
const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
|
|
75314
75292
|
const isDecorator2 = node.kind === 170 /* Decorator */;
|
|
75315
75293
|
const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
|
|
@@ -75352,6 +75330,7 @@ function createTypeChecker(host) {
|
|
|
75352
75330
|
chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error);
|
|
75353
75331
|
chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call);
|
|
75354
75332
|
}
|
|
75333
|
+
const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
|
|
75355
75334
|
if (headMessage) {
|
|
75356
75335
|
chain = chainDiagnosticMessages(chain, headMessage);
|
|
75357
75336
|
}
|
|
@@ -75419,6 +75398,7 @@ function createTypeChecker(host) {
|
|
|
75419
75398
|
map(diags, createDiagnosticMessageChainFromDiagnostic),
|
|
75420
75399
|
Diagnostics.No_overload_matches_this_call
|
|
75421
75400
|
);
|
|
75401
|
+
const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
|
|
75422
75402
|
if (headMessage) {
|
|
75423
75403
|
chain = chainDiagnosticMessages(chain, headMessage);
|
|
75424
75404
|
}
|
|
@@ -75434,21 +75414,21 @@ function createTypeChecker(host) {
|
|
|
75434
75414
|
diagnostics.add(diag2);
|
|
75435
75415
|
}
|
|
75436
75416
|
} else if (candidateForArgumentArityError) {
|
|
75437
|
-
diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args,
|
|
75417
|
+
diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
75438
75418
|
} else if (candidateForTypeArgumentError) {
|
|
75439
75419
|
checkTypeArguments(
|
|
75440
75420
|
candidateForTypeArgumentError,
|
|
75441
75421
|
node.typeArguments,
|
|
75442
75422
|
/*reportErrors*/
|
|
75443
75423
|
true,
|
|
75444
|
-
|
|
75424
|
+
headMessageCallback == null ? void 0 : headMessageCallback()
|
|
75445
75425
|
);
|
|
75446
75426
|
} else {
|
|
75447
75427
|
const signaturesWithCorrectTypeArgumentArity = filter(signatures, (s) => hasCorrectTypeArgumentArity(s, typeArguments));
|
|
75448
75428
|
if (signaturesWithCorrectTypeArgumentArity.length === 0) {
|
|
75449
|
-
diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments,
|
|
75429
|
+
diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
75450
75430
|
} else {
|
|
75451
|
-
diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args,
|
|
75431
|
+
diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
75452
75432
|
}
|
|
75453
75433
|
}
|
|
75454
75434
|
}
|
|
@@ -75756,7 +75736,7 @@ function createTypeChecker(host) {
|
|
|
75756
75736
|
error2(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
|
|
75757
75737
|
return resolveErrorCall(node);
|
|
75758
75738
|
}
|
|
75759
|
-
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
75739
|
+
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags, () => isSyntheticHasInstanceMethodCall(node) ? 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 : void 0);
|
|
75760
75740
|
}
|
|
75761
75741
|
function isGenericFunctionReturningFunction(signature) {
|
|
75762
75742
|
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
|
|
@@ -76053,7 +76033,7 @@ function createTypeChecker(host) {
|
|
|
76053
76033
|
invocationErrorRecovery(apparentType, 0 /* Call */, diag2);
|
|
76054
76034
|
return resolveErrorCall(node);
|
|
76055
76035
|
}
|
|
76056
|
-
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
|
|
76036
|
+
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, () => headMessage);
|
|
76057
76037
|
}
|
|
76058
76038
|
function createSignatureForJSXIntrinsic(node, result) {
|
|
76059
76039
|
const namespace = getJsxNamespaceAt(node);
|
|
@@ -78086,6 +78066,32 @@ function createTypeChecker(host) {
|
|
|
78086
78066
|
function isConstEnumSymbol(symbol) {
|
|
78087
78067
|
return (symbol.flags & 128 /* ConstEnum */) !== 0;
|
|
78088
78068
|
}
|
|
78069
|
+
function getSymbolHasInstanceMethodOfObjectType(type) {
|
|
78070
|
+
const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
|
|
78071
|
+
const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
|
|
78072
|
+
if (hasInstanceProperty) {
|
|
78073
|
+
const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
|
|
78074
|
+
if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
|
|
78075
|
+
return hasInstancePropertyType;
|
|
78076
|
+
}
|
|
78077
|
+
}
|
|
78078
|
+
}
|
|
78079
|
+
function createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType) {
|
|
78080
|
+
const syntheticExpression = createSyntheticExpression(right, hasInstanceMethodType);
|
|
78081
|
+
const syntheticArgument = createSyntheticExpression(left, leftType);
|
|
78082
|
+
const syntheticCall = parseNodeFactory.createCallExpression(
|
|
78083
|
+
syntheticExpression,
|
|
78084
|
+
/*typeArguments*/
|
|
78085
|
+
void 0,
|
|
78086
|
+
[syntheticArgument]
|
|
78087
|
+
);
|
|
78088
|
+
setParent(syntheticCall, left.parent);
|
|
78089
|
+
setTextRange(syntheticCall, left.parent);
|
|
78090
|
+
return syntheticCall;
|
|
78091
|
+
}
|
|
78092
|
+
function isSyntheticHasInstanceMethodCall(node) {
|
|
78093
|
+
return isSyntheticExpression(node.expression) && node.arguments.length === 1 && isSyntheticExpression(node.arguments[0]) && isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 104 /* InstanceOfKeyword */ && node.parent.right === node.expression.parent && node.parent.left === node.arguments[0].parent;
|
|
78094
|
+
}
|
|
78089
78095
|
function checkInstanceOfExpression(left, right, leftType, rightType) {
|
|
78090
78096
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
78091
78097
|
return silentNeverType;
|
|
@@ -78093,8 +78099,31 @@ function createTypeChecker(host) {
|
|
|
78093
78099
|
if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
|
|
78094
78100
|
error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
|
78095
78101
|
}
|
|
78096
|
-
if (!
|
|
78097
|
-
|
|
78102
|
+
if (!isTypeAny(rightType)) {
|
|
78103
|
+
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
|
|
78104
|
+
if (hasInstanceMethodType) {
|
|
78105
|
+
const cache = hasInstanceMethodType;
|
|
78106
|
+
if (cache.hasSimpleUnrestrictedSingleCallSignature === void 0) {
|
|
78107
|
+
const signature = getSingleCallSignature(hasInstanceMethodType);
|
|
78108
|
+
cache.hasSimpleUnrestrictedSingleCallSignature = !!signature && signature.parameters.length === 1 && !!(getTypeOfSymbol(signature.parameters[0]).flags & 3 /* AnyOrUnknown */) && !!signature.resolvedReturnType && !!(signature.resolvedReturnType.flags & 16 /* Boolean */);
|
|
78109
|
+
}
|
|
78110
|
+
if (!cache.hasSimpleUnrestrictedSingleCallSignature) {
|
|
78111
|
+
const syntheticCall = createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType);
|
|
78112
|
+
const returnType = getReturnTypeOfSignature(getResolvedSignature(syntheticCall));
|
|
78113
|
+
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);
|
|
78114
|
+
}
|
|
78115
|
+
}
|
|
78116
|
+
if (!(hasInstanceMethodType || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
|
|
78117
|
+
if (hasGlobalSymbolHasInstanceProperty === void 0) {
|
|
78118
|
+
const globalESSymbolConstructorSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
78119
|
+
/*reportErrors*/
|
|
78120
|
+
false
|
|
78121
|
+
);
|
|
78122
|
+
hasGlobalSymbolHasInstanceProperty = !!globalESSymbolConstructorSymbol && getMembersOfSymbol(globalESSymbolConstructorSymbol).has("hasInstance");
|
|
78123
|
+
}
|
|
78124
|
+
const message = hasGlobalSymbolHasInstanceProperty ? Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Symbol_hasInstance_method_or_a_type_assignable_to_the_Function_interface_type : Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type;
|
|
78125
|
+
error2(right, message);
|
|
78126
|
+
}
|
|
78098
78127
|
}
|
|
78099
78128
|
return booleanType;
|
|
78100
78129
|
}
|
package/lib/tsserverlibrary.d.ts
CHANGED
|
@@ -5139,7 +5139,7 @@ declare namespace ts {
|
|
|
5139
5139
|
readonly asteriskToken?: AsteriskToken;
|
|
5140
5140
|
readonly expression?: Expression;
|
|
5141
5141
|
}
|
|
5142
|
-
interface SyntheticExpression extends
|
|
5142
|
+
interface SyntheticExpression extends LeftHandSideExpression {
|
|
5143
5143
|
readonly kind: SyntaxKind.SyntheticExpression;
|
|
5144
5144
|
readonly isSpread: boolean;
|
|
5145
5145
|
readonly type: Type;
|
package/lib/tsserverlibrary.js
CHANGED
|
@@ -7972,6 +7972,9 @@ ${lanes.join("\n")}
|
|
|
7972
7972
|
await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(2852, 1 /* Error */, "await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_2852", "'await using' statements are only allowed within async functions and at the top levels of modules."),
|
|
7973
7973
|
await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(2853, 1 /* Error */, "await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_th_2853", "'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
7974
7974
|
Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(2854, 1 /* Error */, "Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_sys_2854", "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
7975
|
+
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(2855, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2855", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."),
|
|
7976
|
+
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(2856, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2856", "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."),
|
|
7977
|
+
The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Symbol_hasInstance_method_or_a_type_assignable_to_the_Function_interface_type: diag(2857, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Sym_2857", "The right-hand side of an 'instanceof' expression must be either of type 'any', an object type with a '[Symbol.hasInstance]()' method, or a type assignable to the 'Function' interface type."),
|
|
7975
7978
|
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}'."),
|
|
7976
7979
|
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}'."),
|
|
7977
7980
|
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}'."),
|
|
@@ -12452,6 +12455,7 @@ ${lanes.join("\n")}
|
|
|
12452
12455
|
case 236 /* MetaProperty */:
|
|
12453
12456
|
case 102 /* ImportKeyword */:
|
|
12454
12457
|
case 282 /* MissingDeclaration */:
|
|
12458
|
+
case 237 /* SyntheticExpression */:
|
|
12455
12459
|
return true;
|
|
12456
12460
|
default:
|
|
12457
12461
|
return false;
|
|
@@ -46337,6 +46341,7 @@ ${lanes.join("\n")}
|
|
|
46337
46341
|
var potentialReflectCollisions = [];
|
|
46338
46342
|
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
46339
46343
|
var awaitedTypeStack = [];
|
|
46344
|
+
var hasGlobalSymbolHasInstanceProperty;
|
|
46340
46345
|
var diagnostics = createDiagnosticCollection();
|
|
46341
46346
|
var suggestionDiagnostics = createDiagnosticCollection();
|
|
46342
46347
|
var typeofType = createTypeofType();
|
|
@@ -50658,7 +50663,7 @@ ${lanes.join("\n")}
|
|
|
50658
50663
|
return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */));
|
|
50659
50664
|
}
|
|
50660
50665
|
function addPropertyToElementList(propertySymbol, context, typeElements) {
|
|
50661
|
-
var _a
|
|
50666
|
+
var _a;
|
|
50662
50667
|
const propertyIsReverseMapped = !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */);
|
|
50663
50668
|
const propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol);
|
|
50664
50669
|
const saveEnclosingDeclaration = context.enclosingDeclaration;
|
|
@@ -50708,57 +50713,17 @@ ${lanes.join("\n")}
|
|
|
50708
50713
|
context.reverseMappedStack.pop();
|
|
50709
50714
|
}
|
|
50710
50715
|
}
|
|
50711
|
-
|
|
50712
|
-
|
|
50713
|
-
|
|
50714
|
-
const getAccessorSignature = factory.createGetAccessorDeclaration(
|
|
50715
|
-
/*modifiers*/
|
|
50716
|
-
void 0,
|
|
50717
|
-
propertyName,
|
|
50718
|
-
[],
|
|
50719
|
-
propertyTypeNode,
|
|
50720
|
-
/*body*/
|
|
50721
|
-
void 0
|
|
50722
|
-
);
|
|
50723
|
-
setCommentRange(getAccessorSignature, getAccessorDecl);
|
|
50724
|
-
typeElements.push(getAccessorSignature);
|
|
50725
|
-
}
|
|
50726
|
-
if (propertySymbol.flags & 65536 /* SetAccessor */) {
|
|
50727
|
-
const setAccessorDecl = find(propertySymbol.declarations, (decl) => decl.kind === 178 /* SetAccessor */);
|
|
50728
|
-
const parameterName = ((_b = setAccessorDecl == null ? void 0 : setAccessorDecl.parameters) == null ? void 0 : _b.length) > 0 ? setAccessorDecl.parameters[0].name : "arg";
|
|
50729
|
-
const setAccessorSignature = factory.createSetAccessorDeclaration(
|
|
50730
|
-
/*modifiers*/
|
|
50731
|
-
void 0,
|
|
50732
|
-
propertyName,
|
|
50733
|
-
[factory.createParameterDeclaration(
|
|
50734
|
-
/*modifiers*/
|
|
50735
|
-
void 0,
|
|
50736
|
-
/*dotDotDotToken*/
|
|
50737
|
-
void 0,
|
|
50738
|
-
parameterName,
|
|
50739
|
-
/*questionToken*/
|
|
50740
|
-
void 0,
|
|
50741
|
-
propertyTypeNode
|
|
50742
|
-
)],
|
|
50743
|
-
/*body*/
|
|
50744
|
-
void 0
|
|
50745
|
-
);
|
|
50746
|
-
setCommentRange(setAccessorSignature, setAccessorDecl);
|
|
50747
|
-
typeElements.push(setAccessorSignature);
|
|
50748
|
-
}
|
|
50749
|
-
} else {
|
|
50750
|
-
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
|
|
50751
|
-
if (modifiers) {
|
|
50752
|
-
context.approximateLength += 9;
|
|
50753
|
-
}
|
|
50754
|
-
const propertySignature = factory.createPropertySignature(
|
|
50755
|
-
modifiers,
|
|
50756
|
-
propertyName,
|
|
50757
|
-
optionalToken,
|
|
50758
|
-
propertyTypeNode
|
|
50759
|
-
);
|
|
50760
|
-
typeElements.push(preserveCommentsOn(propertySignature));
|
|
50716
|
+
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
|
|
50717
|
+
if (modifiers) {
|
|
50718
|
+
context.approximateLength += 9;
|
|
50761
50719
|
}
|
|
50720
|
+
const propertySignature = factory.createPropertySignature(
|
|
50721
|
+
modifiers,
|
|
50722
|
+
propertyName,
|
|
50723
|
+
optionalToken,
|
|
50724
|
+
propertyTypeNode
|
|
50725
|
+
);
|
|
50726
|
+
typeElements.push(preserveCommentsOn(propertySignature));
|
|
50762
50727
|
function preserveCommentsOn(node) {
|
|
50763
50728
|
var _a2;
|
|
50764
50729
|
if (some(propertySymbol.declarations, (d) => d.kind === 355 /* JSDocPropertyTag */)) {
|
|
@@ -68419,6 +68384,15 @@ ${lanes.join("\n")}
|
|
|
68419
68384
|
return type;
|
|
68420
68385
|
}
|
|
68421
68386
|
const rightType = getTypeOfExpression(expr.right);
|
|
68387
|
+
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
|
|
68388
|
+
if (hasInstanceMethodType) {
|
|
68389
|
+
const syntheticCall = createSyntheticHasInstanceMethodCall(left, expr.right, type, hasInstanceMethodType);
|
|
68390
|
+
const signature = getEffectsSignature(syntheticCall);
|
|
68391
|
+
const predicate = signature && getTypePredicateOfSignature(signature);
|
|
68392
|
+
if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
|
|
68393
|
+
return narrowTypeByTypePredicate(type, predicate, syntheticCall, assumeTrue);
|
|
68394
|
+
}
|
|
68395
|
+
}
|
|
68422
68396
|
if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
|
|
68423
68397
|
return type;
|
|
68424
68398
|
}
|
|
@@ -68498,8 +68472,12 @@ ${lanes.join("\n")}
|
|
|
68498
68472
|
}
|
|
68499
68473
|
function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
|
|
68500
68474
|
if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
|
|
68501
|
-
|
|
68475
|
+
let predicateArgument = getTypePredicateArgument(predicate, callExpression);
|
|
68502
68476
|
if (predicateArgument) {
|
|
68477
|
+
if (isSyntheticExpression(predicateArgument) && predicate.parameterIndex === 0 && isSyntheticHasInstanceMethodCall(callExpression)) {
|
|
68478
|
+
Debug.assertNode(predicateArgument.parent, isExpression);
|
|
68479
|
+
predicateArgument = predicateArgument.parent;
|
|
68480
|
+
}
|
|
68503
68481
|
if (isMatchingReference(reference, predicateArgument)) {
|
|
68504
68482
|
return getNarrowedType(
|
|
68505
68483
|
type,
|
|
@@ -73076,7 +73054,7 @@ ${lanes.join("\n")}
|
|
|
73076
73054
|
}
|
|
73077
73055
|
return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
|
|
73078
73056
|
}
|
|
73079
|
-
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags,
|
|
73057
|
+
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessageCallback) {
|
|
73080
73058
|
const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
|
|
73081
73059
|
const isDecorator2 = node.kind === 170 /* Decorator */;
|
|
73082
73060
|
const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
|
|
@@ -73119,6 +73097,7 @@ ${lanes.join("\n")}
|
|
|
73119
73097
|
chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error);
|
|
73120
73098
|
chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call);
|
|
73121
73099
|
}
|
|
73100
|
+
const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
|
|
73122
73101
|
if (headMessage) {
|
|
73123
73102
|
chain = chainDiagnosticMessages(chain, headMessage);
|
|
73124
73103
|
}
|
|
@@ -73186,6 +73165,7 @@ ${lanes.join("\n")}
|
|
|
73186
73165
|
map(diags, createDiagnosticMessageChainFromDiagnostic),
|
|
73187
73166
|
Diagnostics.No_overload_matches_this_call
|
|
73188
73167
|
);
|
|
73168
|
+
const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
|
|
73189
73169
|
if (headMessage) {
|
|
73190
73170
|
chain = chainDiagnosticMessages(chain, headMessage);
|
|
73191
73171
|
}
|
|
@@ -73201,21 +73181,21 @@ ${lanes.join("\n")}
|
|
|
73201
73181
|
diagnostics.add(diag2);
|
|
73202
73182
|
}
|
|
73203
73183
|
} else if (candidateForArgumentArityError) {
|
|
73204
|
-
diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args,
|
|
73184
|
+
diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
73205
73185
|
} else if (candidateForTypeArgumentError) {
|
|
73206
73186
|
checkTypeArguments(
|
|
73207
73187
|
candidateForTypeArgumentError,
|
|
73208
73188
|
node.typeArguments,
|
|
73209
73189
|
/*reportErrors*/
|
|
73210
73190
|
true,
|
|
73211
|
-
|
|
73191
|
+
headMessageCallback == null ? void 0 : headMessageCallback()
|
|
73212
73192
|
);
|
|
73213
73193
|
} else {
|
|
73214
73194
|
const signaturesWithCorrectTypeArgumentArity = filter(signatures, (s) => hasCorrectTypeArgumentArity(s, typeArguments));
|
|
73215
73195
|
if (signaturesWithCorrectTypeArgumentArity.length === 0) {
|
|
73216
|
-
diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments,
|
|
73196
|
+
diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
73217
73197
|
} else {
|
|
73218
|
-
diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args,
|
|
73198
|
+
diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
73219
73199
|
}
|
|
73220
73200
|
}
|
|
73221
73201
|
}
|
|
@@ -73523,7 +73503,7 @@ ${lanes.join("\n")}
|
|
|
73523
73503
|
error2(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
|
|
73524
73504
|
return resolveErrorCall(node);
|
|
73525
73505
|
}
|
|
73526
|
-
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
73506
|
+
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags, () => isSyntheticHasInstanceMethodCall(node) ? 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 : void 0);
|
|
73527
73507
|
}
|
|
73528
73508
|
function isGenericFunctionReturningFunction(signature) {
|
|
73529
73509
|
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
|
|
@@ -73820,7 +73800,7 @@ ${lanes.join("\n")}
|
|
|
73820
73800
|
invocationErrorRecovery(apparentType, 0 /* Call */, diag2);
|
|
73821
73801
|
return resolveErrorCall(node);
|
|
73822
73802
|
}
|
|
73823
|
-
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
|
|
73803
|
+
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, () => headMessage);
|
|
73824
73804
|
}
|
|
73825
73805
|
function createSignatureForJSXIntrinsic(node, result) {
|
|
73826
73806
|
const namespace = getJsxNamespaceAt(node);
|
|
@@ -75853,6 +75833,32 @@ ${lanes.join("\n")}
|
|
|
75853
75833
|
function isConstEnumSymbol(symbol) {
|
|
75854
75834
|
return (symbol.flags & 128 /* ConstEnum */) !== 0;
|
|
75855
75835
|
}
|
|
75836
|
+
function getSymbolHasInstanceMethodOfObjectType(type) {
|
|
75837
|
+
const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
|
|
75838
|
+
const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
|
|
75839
|
+
if (hasInstanceProperty) {
|
|
75840
|
+
const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
|
|
75841
|
+
if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
|
|
75842
|
+
return hasInstancePropertyType;
|
|
75843
|
+
}
|
|
75844
|
+
}
|
|
75845
|
+
}
|
|
75846
|
+
function createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType) {
|
|
75847
|
+
const syntheticExpression = createSyntheticExpression(right, hasInstanceMethodType);
|
|
75848
|
+
const syntheticArgument = createSyntheticExpression(left, leftType);
|
|
75849
|
+
const syntheticCall = parseNodeFactory.createCallExpression(
|
|
75850
|
+
syntheticExpression,
|
|
75851
|
+
/*typeArguments*/
|
|
75852
|
+
void 0,
|
|
75853
|
+
[syntheticArgument]
|
|
75854
|
+
);
|
|
75855
|
+
setParent(syntheticCall, left.parent);
|
|
75856
|
+
setTextRange(syntheticCall, left.parent);
|
|
75857
|
+
return syntheticCall;
|
|
75858
|
+
}
|
|
75859
|
+
function isSyntheticHasInstanceMethodCall(node) {
|
|
75860
|
+
return isSyntheticExpression(node.expression) && node.arguments.length === 1 && isSyntheticExpression(node.arguments[0]) && isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 104 /* InstanceOfKeyword */ && node.parent.right === node.expression.parent && node.parent.left === node.arguments[0].parent;
|
|
75861
|
+
}
|
|
75856
75862
|
function checkInstanceOfExpression(left, right, leftType, rightType) {
|
|
75857
75863
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
75858
75864
|
return silentNeverType;
|
|
@@ -75860,8 +75866,31 @@ ${lanes.join("\n")}
|
|
|
75860
75866
|
if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
|
|
75861
75867
|
error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
|
75862
75868
|
}
|
|
75863
|
-
if (!
|
|
75864
|
-
|
|
75869
|
+
if (!isTypeAny(rightType)) {
|
|
75870
|
+
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
|
|
75871
|
+
if (hasInstanceMethodType) {
|
|
75872
|
+
const cache = hasInstanceMethodType;
|
|
75873
|
+
if (cache.hasSimpleUnrestrictedSingleCallSignature === void 0) {
|
|
75874
|
+
const signature = getSingleCallSignature(hasInstanceMethodType);
|
|
75875
|
+
cache.hasSimpleUnrestrictedSingleCallSignature = !!signature && signature.parameters.length === 1 && !!(getTypeOfSymbol(signature.parameters[0]).flags & 3 /* AnyOrUnknown */) && !!signature.resolvedReturnType && !!(signature.resolvedReturnType.flags & 16 /* Boolean */);
|
|
75876
|
+
}
|
|
75877
|
+
if (!cache.hasSimpleUnrestrictedSingleCallSignature) {
|
|
75878
|
+
const syntheticCall = createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType);
|
|
75879
|
+
const returnType = getReturnTypeOfSignature(getResolvedSignature(syntheticCall));
|
|
75880
|
+
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);
|
|
75881
|
+
}
|
|
75882
|
+
}
|
|
75883
|
+
if (!(hasInstanceMethodType || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
|
|
75884
|
+
if (hasGlobalSymbolHasInstanceProperty === void 0) {
|
|
75885
|
+
const globalESSymbolConstructorSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
75886
|
+
/*reportErrors*/
|
|
75887
|
+
false
|
|
75888
|
+
);
|
|
75889
|
+
hasGlobalSymbolHasInstanceProperty = !!globalESSymbolConstructorSymbol && getMembersOfSymbol(globalESSymbolConstructorSymbol).has("hasInstance");
|
|
75890
|
+
}
|
|
75891
|
+
const message = hasGlobalSymbolHasInstanceProperty ? Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Symbol_hasInstance_method_or_a_type_assignable_to_the_Function_interface_type : Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type;
|
|
75892
|
+
error2(right, message);
|
|
75893
|
+
}
|
|
75865
75894
|
}
|
|
75866
75895
|
return booleanType;
|
|
75867
75896
|
}
|
package/lib/typescript.d.ts
CHANGED
|
@@ -1086,7 +1086,7 @@ declare namespace ts {
|
|
|
1086
1086
|
readonly asteriskToken?: AsteriskToken;
|
|
1087
1087
|
readonly expression?: Expression;
|
|
1088
1088
|
}
|
|
1089
|
-
interface SyntheticExpression extends
|
|
1089
|
+
interface SyntheticExpression extends LeftHandSideExpression {
|
|
1090
1090
|
readonly kind: SyntaxKind.SyntheticExpression;
|
|
1091
1091
|
readonly isSpread: boolean;
|
|
1092
1092
|
readonly type: Type;
|
package/lib/typescript.js
CHANGED
|
@@ -7972,6 +7972,9 @@ ${lanes.join("\n")}
|
|
|
7972
7972
|
await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(2852, 1 /* Error */, "await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_2852", "'await using' statements are only allowed within async functions and at the top levels of modules."),
|
|
7973
7973
|
await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(2853, 1 /* Error */, "await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_th_2853", "'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
7974
7974
|
Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(2854, 1 /* Error */, "Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_sys_2854", "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
7975
|
+
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(2855, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2855", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."),
|
|
7976
|
+
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(2856, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2856", "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."),
|
|
7977
|
+
The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Symbol_hasInstance_method_or_a_type_assignable_to_the_Function_interface_type: diag(2857, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Sym_2857", "The right-hand side of an 'instanceof' expression must be either of type 'any', an object type with a '[Symbol.hasInstance]()' method, or a type assignable to the 'Function' interface type."),
|
|
7975
7978
|
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}'."),
|
|
7976
7979
|
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}'."),
|
|
7977
7980
|
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}'."),
|
|
@@ -12452,6 +12455,7 @@ ${lanes.join("\n")}
|
|
|
12452
12455
|
case 236 /* MetaProperty */:
|
|
12453
12456
|
case 102 /* ImportKeyword */:
|
|
12454
12457
|
case 282 /* MissingDeclaration */:
|
|
12458
|
+
case 237 /* SyntheticExpression */:
|
|
12455
12459
|
return true;
|
|
12456
12460
|
default:
|
|
12457
12461
|
return false;
|
|
@@ -46337,6 +46341,7 @@ ${lanes.join("\n")}
|
|
|
46337
46341
|
var potentialReflectCollisions = [];
|
|
46338
46342
|
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
46339
46343
|
var awaitedTypeStack = [];
|
|
46344
|
+
var hasGlobalSymbolHasInstanceProperty;
|
|
46340
46345
|
var diagnostics = createDiagnosticCollection();
|
|
46341
46346
|
var suggestionDiagnostics = createDiagnosticCollection();
|
|
46342
46347
|
var typeofType = createTypeofType();
|
|
@@ -50658,7 +50663,7 @@ ${lanes.join("\n")}
|
|
|
50658
50663
|
return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */));
|
|
50659
50664
|
}
|
|
50660
50665
|
function addPropertyToElementList(propertySymbol, context, typeElements) {
|
|
50661
|
-
var _a
|
|
50666
|
+
var _a;
|
|
50662
50667
|
const propertyIsReverseMapped = !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */);
|
|
50663
50668
|
const propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol);
|
|
50664
50669
|
const saveEnclosingDeclaration = context.enclosingDeclaration;
|
|
@@ -50708,57 +50713,17 @@ ${lanes.join("\n")}
|
|
|
50708
50713
|
context.reverseMappedStack.pop();
|
|
50709
50714
|
}
|
|
50710
50715
|
}
|
|
50711
|
-
|
|
50712
|
-
|
|
50713
|
-
|
|
50714
|
-
const getAccessorSignature = factory.createGetAccessorDeclaration(
|
|
50715
|
-
/*modifiers*/
|
|
50716
|
-
void 0,
|
|
50717
|
-
propertyName,
|
|
50718
|
-
[],
|
|
50719
|
-
propertyTypeNode,
|
|
50720
|
-
/*body*/
|
|
50721
|
-
void 0
|
|
50722
|
-
);
|
|
50723
|
-
setCommentRange(getAccessorSignature, getAccessorDecl);
|
|
50724
|
-
typeElements.push(getAccessorSignature);
|
|
50725
|
-
}
|
|
50726
|
-
if (propertySymbol.flags & 65536 /* SetAccessor */) {
|
|
50727
|
-
const setAccessorDecl = find(propertySymbol.declarations, (decl) => decl.kind === 178 /* SetAccessor */);
|
|
50728
|
-
const parameterName = ((_b = setAccessorDecl == null ? void 0 : setAccessorDecl.parameters) == null ? void 0 : _b.length) > 0 ? setAccessorDecl.parameters[0].name : "arg";
|
|
50729
|
-
const setAccessorSignature = factory.createSetAccessorDeclaration(
|
|
50730
|
-
/*modifiers*/
|
|
50731
|
-
void 0,
|
|
50732
|
-
propertyName,
|
|
50733
|
-
[factory.createParameterDeclaration(
|
|
50734
|
-
/*modifiers*/
|
|
50735
|
-
void 0,
|
|
50736
|
-
/*dotDotDotToken*/
|
|
50737
|
-
void 0,
|
|
50738
|
-
parameterName,
|
|
50739
|
-
/*questionToken*/
|
|
50740
|
-
void 0,
|
|
50741
|
-
propertyTypeNode
|
|
50742
|
-
)],
|
|
50743
|
-
/*body*/
|
|
50744
|
-
void 0
|
|
50745
|
-
);
|
|
50746
|
-
setCommentRange(setAccessorSignature, setAccessorDecl);
|
|
50747
|
-
typeElements.push(setAccessorSignature);
|
|
50748
|
-
}
|
|
50749
|
-
} else {
|
|
50750
|
-
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
|
|
50751
|
-
if (modifiers) {
|
|
50752
|
-
context.approximateLength += 9;
|
|
50753
|
-
}
|
|
50754
|
-
const propertySignature = factory.createPropertySignature(
|
|
50755
|
-
modifiers,
|
|
50756
|
-
propertyName,
|
|
50757
|
-
optionalToken,
|
|
50758
|
-
propertyTypeNode
|
|
50759
|
-
);
|
|
50760
|
-
typeElements.push(preserveCommentsOn(propertySignature));
|
|
50716
|
+
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
|
|
50717
|
+
if (modifiers) {
|
|
50718
|
+
context.approximateLength += 9;
|
|
50761
50719
|
}
|
|
50720
|
+
const propertySignature = factory.createPropertySignature(
|
|
50721
|
+
modifiers,
|
|
50722
|
+
propertyName,
|
|
50723
|
+
optionalToken,
|
|
50724
|
+
propertyTypeNode
|
|
50725
|
+
);
|
|
50726
|
+
typeElements.push(preserveCommentsOn(propertySignature));
|
|
50762
50727
|
function preserveCommentsOn(node) {
|
|
50763
50728
|
var _a2;
|
|
50764
50729
|
if (some(propertySymbol.declarations, (d) => d.kind === 355 /* JSDocPropertyTag */)) {
|
|
@@ -68419,6 +68384,15 @@ ${lanes.join("\n")}
|
|
|
68419
68384
|
return type;
|
|
68420
68385
|
}
|
|
68421
68386
|
const rightType = getTypeOfExpression(expr.right);
|
|
68387
|
+
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
|
|
68388
|
+
if (hasInstanceMethodType) {
|
|
68389
|
+
const syntheticCall = createSyntheticHasInstanceMethodCall(left, expr.right, type, hasInstanceMethodType);
|
|
68390
|
+
const signature = getEffectsSignature(syntheticCall);
|
|
68391
|
+
const predicate = signature && getTypePredicateOfSignature(signature);
|
|
68392
|
+
if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
|
|
68393
|
+
return narrowTypeByTypePredicate(type, predicate, syntheticCall, assumeTrue);
|
|
68394
|
+
}
|
|
68395
|
+
}
|
|
68422
68396
|
if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
|
|
68423
68397
|
return type;
|
|
68424
68398
|
}
|
|
@@ -68498,8 +68472,12 @@ ${lanes.join("\n")}
|
|
|
68498
68472
|
}
|
|
68499
68473
|
function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
|
|
68500
68474
|
if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
|
|
68501
|
-
|
|
68475
|
+
let predicateArgument = getTypePredicateArgument(predicate, callExpression);
|
|
68502
68476
|
if (predicateArgument) {
|
|
68477
|
+
if (isSyntheticExpression(predicateArgument) && predicate.parameterIndex === 0 && isSyntheticHasInstanceMethodCall(callExpression)) {
|
|
68478
|
+
Debug.assertNode(predicateArgument.parent, isExpression);
|
|
68479
|
+
predicateArgument = predicateArgument.parent;
|
|
68480
|
+
}
|
|
68503
68481
|
if (isMatchingReference(reference, predicateArgument)) {
|
|
68504
68482
|
return getNarrowedType(
|
|
68505
68483
|
type,
|
|
@@ -73076,7 +73054,7 @@ ${lanes.join("\n")}
|
|
|
73076
73054
|
}
|
|
73077
73055
|
return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
|
|
73078
73056
|
}
|
|
73079
|
-
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags,
|
|
73057
|
+
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessageCallback) {
|
|
73080
73058
|
const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
|
|
73081
73059
|
const isDecorator2 = node.kind === 170 /* Decorator */;
|
|
73082
73060
|
const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
|
|
@@ -73119,6 +73097,7 @@ ${lanes.join("\n")}
|
|
|
73119
73097
|
chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error);
|
|
73120
73098
|
chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call);
|
|
73121
73099
|
}
|
|
73100
|
+
const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
|
|
73122
73101
|
if (headMessage) {
|
|
73123
73102
|
chain = chainDiagnosticMessages(chain, headMessage);
|
|
73124
73103
|
}
|
|
@@ -73186,6 +73165,7 @@ ${lanes.join("\n")}
|
|
|
73186
73165
|
map(diags, createDiagnosticMessageChainFromDiagnostic),
|
|
73187
73166
|
Diagnostics.No_overload_matches_this_call
|
|
73188
73167
|
);
|
|
73168
|
+
const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
|
|
73189
73169
|
if (headMessage) {
|
|
73190
73170
|
chain = chainDiagnosticMessages(chain, headMessage);
|
|
73191
73171
|
}
|
|
@@ -73201,21 +73181,21 @@ ${lanes.join("\n")}
|
|
|
73201
73181
|
diagnostics.add(diag2);
|
|
73202
73182
|
}
|
|
73203
73183
|
} else if (candidateForArgumentArityError) {
|
|
73204
|
-
diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args,
|
|
73184
|
+
diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
73205
73185
|
} else if (candidateForTypeArgumentError) {
|
|
73206
73186
|
checkTypeArguments(
|
|
73207
73187
|
candidateForTypeArgumentError,
|
|
73208
73188
|
node.typeArguments,
|
|
73209
73189
|
/*reportErrors*/
|
|
73210
73190
|
true,
|
|
73211
|
-
|
|
73191
|
+
headMessageCallback == null ? void 0 : headMessageCallback()
|
|
73212
73192
|
);
|
|
73213
73193
|
} else {
|
|
73214
73194
|
const signaturesWithCorrectTypeArgumentArity = filter(signatures, (s) => hasCorrectTypeArgumentArity(s, typeArguments));
|
|
73215
73195
|
if (signaturesWithCorrectTypeArgumentArity.length === 0) {
|
|
73216
|
-
diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments,
|
|
73196
|
+
diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
73217
73197
|
} else {
|
|
73218
|
-
diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args,
|
|
73198
|
+
diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessageCallback == null ? void 0 : headMessageCallback()));
|
|
73219
73199
|
}
|
|
73220
73200
|
}
|
|
73221
73201
|
}
|
|
@@ -73523,7 +73503,7 @@ ${lanes.join("\n")}
|
|
|
73523
73503
|
error2(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
|
|
73524
73504
|
return resolveErrorCall(node);
|
|
73525
73505
|
}
|
|
73526
|
-
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
73506
|
+
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags, () => isSyntheticHasInstanceMethodCall(node) ? 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 : void 0);
|
|
73527
73507
|
}
|
|
73528
73508
|
function isGenericFunctionReturningFunction(signature) {
|
|
73529
73509
|
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
|
|
@@ -73820,7 +73800,7 @@ ${lanes.join("\n")}
|
|
|
73820
73800
|
invocationErrorRecovery(apparentType, 0 /* Call */, diag2);
|
|
73821
73801
|
return resolveErrorCall(node);
|
|
73822
73802
|
}
|
|
73823
|
-
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
|
|
73803
|
+
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, () => headMessage);
|
|
73824
73804
|
}
|
|
73825
73805
|
function createSignatureForJSXIntrinsic(node, result) {
|
|
73826
73806
|
const namespace = getJsxNamespaceAt(node);
|
|
@@ -75853,6 +75833,32 @@ ${lanes.join("\n")}
|
|
|
75853
75833
|
function isConstEnumSymbol(symbol) {
|
|
75854
75834
|
return (symbol.flags & 128 /* ConstEnum */) !== 0;
|
|
75855
75835
|
}
|
|
75836
|
+
function getSymbolHasInstanceMethodOfObjectType(type) {
|
|
75837
|
+
const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
|
|
75838
|
+
const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
|
|
75839
|
+
if (hasInstanceProperty) {
|
|
75840
|
+
const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
|
|
75841
|
+
if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
|
|
75842
|
+
return hasInstancePropertyType;
|
|
75843
|
+
}
|
|
75844
|
+
}
|
|
75845
|
+
}
|
|
75846
|
+
function createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType) {
|
|
75847
|
+
const syntheticExpression = createSyntheticExpression(right, hasInstanceMethodType);
|
|
75848
|
+
const syntheticArgument = createSyntheticExpression(left, leftType);
|
|
75849
|
+
const syntheticCall = parseNodeFactory.createCallExpression(
|
|
75850
|
+
syntheticExpression,
|
|
75851
|
+
/*typeArguments*/
|
|
75852
|
+
void 0,
|
|
75853
|
+
[syntheticArgument]
|
|
75854
|
+
);
|
|
75855
|
+
setParent(syntheticCall, left.parent);
|
|
75856
|
+
setTextRange(syntheticCall, left.parent);
|
|
75857
|
+
return syntheticCall;
|
|
75858
|
+
}
|
|
75859
|
+
function isSyntheticHasInstanceMethodCall(node) {
|
|
75860
|
+
return isSyntheticExpression(node.expression) && node.arguments.length === 1 && isSyntheticExpression(node.arguments[0]) && isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 104 /* InstanceOfKeyword */ && node.parent.right === node.expression.parent && node.parent.left === node.arguments[0].parent;
|
|
75861
|
+
}
|
|
75856
75862
|
function checkInstanceOfExpression(left, right, leftType, rightType) {
|
|
75857
75863
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
75858
75864
|
return silentNeverType;
|
|
@@ -75860,8 +75866,31 @@ ${lanes.join("\n")}
|
|
|
75860
75866
|
if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
|
|
75861
75867
|
error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
|
75862
75868
|
}
|
|
75863
|
-
if (!
|
|
75864
|
-
|
|
75869
|
+
if (!isTypeAny(rightType)) {
|
|
75870
|
+
const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
|
|
75871
|
+
if (hasInstanceMethodType) {
|
|
75872
|
+
const cache = hasInstanceMethodType;
|
|
75873
|
+
if (cache.hasSimpleUnrestrictedSingleCallSignature === void 0) {
|
|
75874
|
+
const signature = getSingleCallSignature(hasInstanceMethodType);
|
|
75875
|
+
cache.hasSimpleUnrestrictedSingleCallSignature = !!signature && signature.parameters.length === 1 && !!(getTypeOfSymbol(signature.parameters[0]).flags & 3 /* AnyOrUnknown */) && !!signature.resolvedReturnType && !!(signature.resolvedReturnType.flags & 16 /* Boolean */);
|
|
75876
|
+
}
|
|
75877
|
+
if (!cache.hasSimpleUnrestrictedSingleCallSignature) {
|
|
75878
|
+
const syntheticCall = createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType);
|
|
75879
|
+
const returnType = getReturnTypeOfSignature(getResolvedSignature(syntheticCall));
|
|
75880
|
+
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);
|
|
75881
|
+
}
|
|
75882
|
+
}
|
|
75883
|
+
if (!(hasInstanceMethodType || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
|
|
75884
|
+
if (hasGlobalSymbolHasInstanceProperty === void 0) {
|
|
75885
|
+
const globalESSymbolConstructorSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
75886
|
+
/*reportErrors*/
|
|
75887
|
+
false
|
|
75888
|
+
);
|
|
75889
|
+
hasGlobalSymbolHasInstanceProperty = !!globalESSymbolConstructorSymbol && getMembersOfSymbol(globalESSymbolConstructorSymbol).has("hasInstance");
|
|
75890
|
+
}
|
|
75891
|
+
const message = hasGlobalSymbolHasInstanceProperty ? Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Symbol_hasInstance_method_or_a_type_assignable_to_the_Function_interface_type : Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type;
|
|
75892
|
+
error2(right, message);
|
|
75893
|
+
}
|
|
75865
75894
|
}
|
|
75866
75895
|
return booleanType;
|
|
75867
75896
|
}
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -6042,6 +6042,9 @@ var Diagnostics = {
|
|
|
6042
6042
|
await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(2852, 1 /* Error */, "await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_2852", "'await using' statements are only allowed within async functions and at the top levels of modules."),
|
|
6043
6043
|
await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(2853, 1 /* Error */, "await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_th_2853", "'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
6044
6044
|
Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(2854, 1 /* Error */, "Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_sys_2854", "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
6045
|
+
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(2855, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2855", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."),
|
|
6046
|
+
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(2856, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2856", "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."),
|
|
6047
|
+
The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Symbol_hasInstance_method_or_a_type_assignable_to_the_Function_interface_type: diag(2857, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_an_object_type_with_a_Sym_2857", "The right-hand side of an 'instanceof' expression must be either of type 'any', an object type with a '[Symbol.hasInstance]()' method, or a type assignable to the 'Function' interface type."),
|
|
6045
6048
|
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}'."),
|
|
6046
6049
|
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}'."),
|
|
6047
6050
|
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}'."),
|
|
@@ -9871,6 +9874,7 @@ function isLeftHandSideExpressionKind(kind) {
|
|
|
9871
9874
|
case 236 /* MetaProperty */:
|
|
9872
9875
|
case 102 /* ImportKeyword */:
|
|
9873
9876
|
case 282 /* MissingDeclaration */:
|
|
9877
|
+
case 237 /* SyntheticExpression */:
|
|
9874
9878
|
return true;
|
|
9875
9879
|
default:
|
|
9876
9880
|
return false;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@typescript-deploys/pr-build",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.2.0-pr-
|
|
5
|
+
"version": "5.2.0-pr-55052-3",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
"node": "20.1.0",
|
|
115
115
|
"npm": "8.19.4"
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "4c0125c23185bb0cba8a8f4397a0748662da3d8c"
|
|
118
118
|
}
|