@typescript-deploys/pr-build 5.3.0-pr-55319-8 → 5.3.0-pr-55052-14

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 CHANGED
@@ -6670,6 +6670,9 @@ var Diagnostics = {
6670
6670
  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."),
6671
6671
  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."),
6672
6672
  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."),
6673
+ 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."),
6674
+ 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."),
6675
+ 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."),
6673
6676
  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}'."),
6674
6677
  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}'."),
6675
6678
  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}'."),
@@ -10993,6 +10996,7 @@ function isLeftHandSideExpressionKind(kind) {
10993
10996
  case 236 /* MetaProperty */:
10994
10997
  case 102 /* ImportKeyword */:
10995
10998
  case 282 /* MissingDeclaration */:
10999
+ case 237 /* SyntheticExpression */:
10996
11000
  return true;
10997
11001
  default:
10998
11002
  return false;
@@ -24296,6 +24300,9 @@ function isNonNullExpression(node) {
24296
24300
  function isMetaProperty(node) {
24297
24301
  return node.kind === 236 /* MetaProperty */;
24298
24302
  }
24303
+ function isSyntheticExpression(node) {
24304
+ return node.kind === 237 /* SyntheticExpression */;
24305
+ }
24299
24306
  function isPartiallyEmittedExpression(node) {
24300
24307
  return node.kind === 360 /* PartiallyEmittedExpression */;
24301
24308
  }
@@ -43899,6 +43906,7 @@ function createTypeChecker(host) {
43899
43906
  var potentialReflectCollisions = [];
43900
43907
  var potentialUnusedRenamedBindingElementsInTypes = [];
43901
43908
  var awaitedTypeStack = [];
43909
+ var hasGlobalSymbolHasInstanceProperty;
43902
43910
  var diagnostics = createDiagnosticCollection();
43903
43911
  var suggestionDiagnostics = createDiagnosticCollection();
43904
43912
  var typeofType = createTypeofType();
@@ -65977,6 +65985,15 @@ function createTypeChecker(host) {
65977
65985
  return type;
65978
65986
  }
65979
65987
  const rightType = getTypeOfExpression(expr.right);
65988
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
65989
+ if (hasInstanceMethodType) {
65990
+ const syntheticCall = createSyntheticHasInstanceMethodCall(left, expr.right, type, hasInstanceMethodType);
65991
+ const signature = getEffectsSignature(syntheticCall);
65992
+ const predicate = signature && getTypePredicateOfSignature(signature);
65993
+ if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
65994
+ return narrowTypeByTypePredicate(type, predicate, syntheticCall, assumeTrue);
65995
+ }
65996
+ }
65980
65997
  if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
65981
65998
  return type;
65982
65999
  }
@@ -66056,8 +66073,12 @@ function createTypeChecker(host) {
66056
66073
  }
66057
66074
  function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
66058
66075
  if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
66059
- const predicateArgument = getTypePredicateArgument(predicate, callExpression);
66076
+ let predicateArgument = getTypePredicateArgument(predicate, callExpression);
66060
66077
  if (predicateArgument) {
66078
+ if (isSyntheticExpression(predicateArgument) && predicate.parameterIndex === 0 && isSyntheticHasInstanceMethodCall(callExpression)) {
66079
+ Debug.assertNode(predicateArgument.parent, isExpression);
66080
+ predicateArgument = predicateArgument.parent;
66081
+ }
66061
66082
  if (isMatchingReference(reference, predicateArgument)) {
66062
66083
  return getNarrowedType(
66063
66084
  type,
@@ -70633,7 +70654,7 @@ function createTypeChecker(host) {
70633
70654
  }
70634
70655
  return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
70635
70656
  }
70636
- function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessage) {
70657
+ function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessageCallback) {
70637
70658
  const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
70638
70659
  const isDecorator2 = node.kind === 170 /* Decorator */;
70639
70660
  const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
@@ -70676,6 +70697,7 @@ function createTypeChecker(host) {
70676
70697
  chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error);
70677
70698
  chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call);
70678
70699
  }
70700
+ const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
70679
70701
  if (headMessage) {
70680
70702
  chain = chainDiagnosticMessages(chain, headMessage);
70681
70703
  }
@@ -70743,6 +70765,7 @@ function createTypeChecker(host) {
70743
70765
  map(diags, createDiagnosticMessageChainFromDiagnostic),
70744
70766
  Diagnostics.No_overload_matches_this_call
70745
70767
  );
70768
+ const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
70746
70769
  if (headMessage) {
70747
70770
  chain = chainDiagnosticMessages(chain, headMessage);
70748
70771
  }
@@ -70758,21 +70781,21 @@ function createTypeChecker(host) {
70758
70781
  diagnostics.add(diag2);
70759
70782
  }
70760
70783
  } else if (candidateForArgumentArityError) {
70761
- diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessage));
70784
+ diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessageCallback == null ? void 0 : headMessageCallback()));
70762
70785
  } else if (candidateForTypeArgumentError) {
70763
70786
  checkTypeArguments(
70764
70787
  candidateForTypeArgumentError,
70765
70788
  node.typeArguments,
70766
70789
  /*reportErrors*/
70767
70790
  true,
70768
- headMessage
70791
+ headMessageCallback == null ? void 0 : headMessageCallback()
70769
70792
  );
70770
70793
  } else {
70771
70794
  const signaturesWithCorrectTypeArgumentArity = filter(signatures, (s) => hasCorrectTypeArgumentArity(s, typeArguments));
70772
70795
  if (signaturesWithCorrectTypeArgumentArity.length === 0) {
70773
- diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessage));
70796
+ diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessageCallback == null ? void 0 : headMessageCallback()));
70774
70797
  } else {
70775
- diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessage));
70798
+ diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessageCallback == null ? void 0 : headMessageCallback()));
70776
70799
  }
70777
70800
  }
70778
70801
  }
@@ -71080,7 +71103,7 @@ function createTypeChecker(host) {
71080
71103
  error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
71081
71104
  return resolveErrorCall(node);
71082
71105
  }
71083
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
71106
+ 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);
71084
71107
  }
71085
71108
  function isGenericFunctionReturningFunction(signature) {
71086
71109
  return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@@ -71377,7 +71400,7 @@ function createTypeChecker(host) {
71377
71400
  invocationErrorRecovery(apparentType, 0 /* Call */, diag2);
71378
71401
  return resolveErrorCall(node);
71379
71402
  }
71380
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
71403
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, () => headMessage);
71381
71404
  }
71382
71405
  function createSignatureForJSXIntrinsic(node, result) {
71383
71406
  const namespace = getJsxNamespaceAt(node);
@@ -73419,6 +73442,32 @@ function createTypeChecker(host) {
73419
73442
  function isConstEnumSymbol(symbol) {
73420
73443
  return (symbol.flags & 128 /* ConstEnum */) !== 0;
73421
73444
  }
73445
+ function getSymbolHasInstanceMethodOfObjectType(type) {
73446
+ const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
73447
+ const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
73448
+ if (hasInstanceProperty) {
73449
+ const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
73450
+ if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
73451
+ return hasInstancePropertyType;
73452
+ }
73453
+ }
73454
+ }
73455
+ function createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType) {
73456
+ const syntheticExpression = createSyntheticExpression(right, hasInstanceMethodType);
73457
+ const syntheticArgument = createSyntheticExpression(left, leftType);
73458
+ const syntheticCall = parseNodeFactory.createCallExpression(
73459
+ syntheticExpression,
73460
+ /*typeArguments*/
73461
+ void 0,
73462
+ [syntheticArgument]
73463
+ );
73464
+ setParent(syntheticCall, left.parent);
73465
+ setTextRange(syntheticCall, left.parent);
73466
+ return syntheticCall;
73467
+ }
73468
+ function isSyntheticHasInstanceMethodCall(node) {
73469
+ 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;
73470
+ }
73422
73471
  function checkInstanceOfExpression(left, right, leftType, rightType) {
73423
73472
  if (leftType === silentNeverType || rightType === silentNeverType) {
73424
73473
  return silentNeverType;
@@ -73426,8 +73475,31 @@ function createTypeChecker(host) {
73426
73475
  if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
73427
73476
  error(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
73428
73477
  }
73429
- if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
73430
- 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);
73478
+ if (!isTypeAny(rightType)) {
73479
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
73480
+ if (hasInstanceMethodType) {
73481
+ const cache = hasInstanceMethodType;
73482
+ if (cache.hasSimpleUnrestrictedSingleCallSignature === void 0) {
73483
+ const signature = getSingleCallSignature(hasInstanceMethodType);
73484
+ cache.hasSimpleUnrestrictedSingleCallSignature = !!signature && signature.parameters.length === 1 && !!(getTypeOfSymbol(signature.parameters[0]).flags & 3 /* AnyOrUnknown */) && !!signature.resolvedReturnType && !!(signature.resolvedReturnType.flags & 16 /* Boolean */);
73485
+ }
73486
+ if (!cache.hasSimpleUnrestrictedSingleCallSignature) {
73487
+ const syntheticCall = createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType);
73488
+ const returnType = getReturnTypeOfSignature(getResolvedSignature(syntheticCall));
73489
+ 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);
73490
+ }
73491
+ }
73492
+ if (!(hasInstanceMethodType || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
73493
+ if (hasGlobalSymbolHasInstanceProperty === void 0) {
73494
+ const globalESSymbolConstructorSymbol = getGlobalESSymbolConstructorTypeSymbol(
73495
+ /*reportErrors*/
73496
+ false
73497
+ );
73498
+ hasGlobalSymbolHasInstanceProperty = !!globalESSymbolConstructorSymbol && getMembersOfSymbol(globalESSymbolConstructorSymbol).has("hasInstance");
73499
+ }
73500
+ 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;
73501
+ error(right, message);
73502
+ }
73431
73503
  }
73432
73504
  return booleanType;
73433
73505
  }
@@ -73837,11 +73909,6 @@ function createTypeChecker(host) {
73837
73909
  }
73838
73910
  leftType = checkNonNullType(leftType, left);
73839
73911
  rightType = checkNonNullType(rightType, right);
73840
- if (leftType.flags & rightType.flags & 1024 /* EnumLiteral */) {
73841
- if (getBaseTypeOfEnumLikeType(leftType).symbol !== getBaseTypeOfEnumLikeType(rightType).symbol) {
73842
- error(errorNode, Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations);
73843
- }
73844
- }
73845
73912
  let suggestedOperator;
73846
73913
  if (leftType.flags & 528 /* BooleanLike */ && rightType.flags & 528 /* BooleanLike */ && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== void 0) {
73847
73914
  error(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
package/lib/tsserver.js CHANGED
@@ -10193,6 +10193,9 @@ var Diagnostics = {
10193
10193
  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."),
10194
10194
  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."),
10195
10195
  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."),
10196
+ 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."),
10197
+ 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."),
10198
+ 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."),
10196
10199
  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}'."),
10197
10200
  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}'."),
10198
10201
  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}'."),
@@ -14666,6 +14669,7 @@ function isLeftHandSideExpressionKind(kind) {
14666
14669
  case 236 /* MetaProperty */:
14667
14670
  case 102 /* ImportKeyword */:
14668
14671
  case 282 /* MissingDeclaration */:
14672
+ case 237 /* SyntheticExpression */:
14669
14673
  return true;
14670
14674
  default:
14671
14675
  return false;
@@ -48608,6 +48612,7 @@ function createTypeChecker(host) {
48608
48612
  var potentialReflectCollisions = [];
48609
48613
  var potentialUnusedRenamedBindingElementsInTypes = [];
48610
48614
  var awaitedTypeStack = [];
48615
+ var hasGlobalSymbolHasInstanceProperty;
48611
48616
  var diagnostics = createDiagnosticCollection();
48612
48617
  var suggestionDiagnostics = createDiagnosticCollection();
48613
48618
  var typeofType = createTypeofType();
@@ -70686,6 +70691,15 @@ function createTypeChecker(host) {
70686
70691
  return type;
70687
70692
  }
70688
70693
  const rightType = getTypeOfExpression(expr.right);
70694
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
70695
+ if (hasInstanceMethodType) {
70696
+ const syntheticCall = createSyntheticHasInstanceMethodCall(left, expr.right, type, hasInstanceMethodType);
70697
+ const signature = getEffectsSignature(syntheticCall);
70698
+ const predicate = signature && getTypePredicateOfSignature(signature);
70699
+ if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
70700
+ return narrowTypeByTypePredicate(type, predicate, syntheticCall, assumeTrue);
70701
+ }
70702
+ }
70689
70703
  if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
70690
70704
  return type;
70691
70705
  }
@@ -70765,8 +70779,12 @@ function createTypeChecker(host) {
70765
70779
  }
70766
70780
  function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
70767
70781
  if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
70768
- const predicateArgument = getTypePredicateArgument(predicate, callExpression);
70782
+ let predicateArgument = getTypePredicateArgument(predicate, callExpression);
70769
70783
  if (predicateArgument) {
70784
+ if (isSyntheticExpression(predicateArgument) && predicate.parameterIndex === 0 && isSyntheticHasInstanceMethodCall(callExpression)) {
70785
+ Debug.assertNode(predicateArgument.parent, isExpression);
70786
+ predicateArgument = predicateArgument.parent;
70787
+ }
70770
70788
  if (isMatchingReference(reference, predicateArgument)) {
70771
70789
  return getNarrowedType(
70772
70790
  type,
@@ -75342,7 +75360,7 @@ function createTypeChecker(host) {
75342
75360
  }
75343
75361
  return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
75344
75362
  }
75345
- function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessage) {
75363
+ function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessageCallback) {
75346
75364
  const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
75347
75365
  const isDecorator2 = node.kind === 170 /* Decorator */;
75348
75366
  const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
@@ -75385,6 +75403,7 @@ function createTypeChecker(host) {
75385
75403
  chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error);
75386
75404
  chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call);
75387
75405
  }
75406
+ const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
75388
75407
  if (headMessage) {
75389
75408
  chain = chainDiagnosticMessages(chain, headMessage);
75390
75409
  }
@@ -75452,6 +75471,7 @@ function createTypeChecker(host) {
75452
75471
  map(diags, createDiagnosticMessageChainFromDiagnostic),
75453
75472
  Diagnostics.No_overload_matches_this_call
75454
75473
  );
75474
+ const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
75455
75475
  if (headMessage) {
75456
75476
  chain = chainDiagnosticMessages(chain, headMessage);
75457
75477
  }
@@ -75467,21 +75487,21 @@ function createTypeChecker(host) {
75467
75487
  diagnostics.add(diag2);
75468
75488
  }
75469
75489
  } else if (candidateForArgumentArityError) {
75470
- diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessage));
75490
+ diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessageCallback == null ? void 0 : headMessageCallback()));
75471
75491
  } else if (candidateForTypeArgumentError) {
75472
75492
  checkTypeArguments(
75473
75493
  candidateForTypeArgumentError,
75474
75494
  node.typeArguments,
75475
75495
  /*reportErrors*/
75476
75496
  true,
75477
- headMessage
75497
+ headMessageCallback == null ? void 0 : headMessageCallback()
75478
75498
  );
75479
75499
  } else {
75480
75500
  const signaturesWithCorrectTypeArgumentArity = filter(signatures, (s) => hasCorrectTypeArgumentArity(s, typeArguments));
75481
75501
  if (signaturesWithCorrectTypeArgumentArity.length === 0) {
75482
- diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessage));
75502
+ diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessageCallback == null ? void 0 : headMessageCallback()));
75483
75503
  } else {
75484
- diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessage));
75504
+ diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessageCallback == null ? void 0 : headMessageCallback()));
75485
75505
  }
75486
75506
  }
75487
75507
  }
@@ -75789,7 +75809,7 @@ function createTypeChecker(host) {
75789
75809
  error2(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
75790
75810
  return resolveErrorCall(node);
75791
75811
  }
75792
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
75812
+ 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);
75793
75813
  }
75794
75814
  function isGenericFunctionReturningFunction(signature) {
75795
75815
  return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@@ -76086,7 +76106,7 @@ function createTypeChecker(host) {
76086
76106
  invocationErrorRecovery(apparentType, 0 /* Call */, diag2);
76087
76107
  return resolveErrorCall(node);
76088
76108
  }
76089
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
76109
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, () => headMessage);
76090
76110
  }
76091
76111
  function createSignatureForJSXIntrinsic(node, result) {
76092
76112
  const namespace = getJsxNamespaceAt(node);
@@ -78128,6 +78148,32 @@ function createTypeChecker(host) {
78128
78148
  function isConstEnumSymbol(symbol) {
78129
78149
  return (symbol.flags & 128 /* ConstEnum */) !== 0;
78130
78150
  }
78151
+ function getSymbolHasInstanceMethodOfObjectType(type) {
78152
+ const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
78153
+ const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
78154
+ if (hasInstanceProperty) {
78155
+ const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
78156
+ if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
78157
+ return hasInstancePropertyType;
78158
+ }
78159
+ }
78160
+ }
78161
+ function createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType) {
78162
+ const syntheticExpression = createSyntheticExpression(right, hasInstanceMethodType);
78163
+ const syntheticArgument = createSyntheticExpression(left, leftType);
78164
+ const syntheticCall = parseNodeFactory.createCallExpression(
78165
+ syntheticExpression,
78166
+ /*typeArguments*/
78167
+ void 0,
78168
+ [syntheticArgument]
78169
+ );
78170
+ setParent(syntheticCall, left.parent);
78171
+ setTextRange(syntheticCall, left.parent);
78172
+ return syntheticCall;
78173
+ }
78174
+ function isSyntheticHasInstanceMethodCall(node) {
78175
+ 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;
78176
+ }
78131
78177
  function checkInstanceOfExpression(left, right, leftType, rightType) {
78132
78178
  if (leftType === silentNeverType || rightType === silentNeverType) {
78133
78179
  return silentNeverType;
@@ -78135,8 +78181,31 @@ function createTypeChecker(host) {
78135
78181
  if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
78136
78182
  error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
78137
78183
  }
78138
- if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
78139
- error2(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);
78184
+ if (!isTypeAny(rightType)) {
78185
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
78186
+ if (hasInstanceMethodType) {
78187
+ const cache = hasInstanceMethodType;
78188
+ if (cache.hasSimpleUnrestrictedSingleCallSignature === void 0) {
78189
+ const signature = getSingleCallSignature(hasInstanceMethodType);
78190
+ cache.hasSimpleUnrestrictedSingleCallSignature = !!signature && signature.parameters.length === 1 && !!(getTypeOfSymbol(signature.parameters[0]).flags & 3 /* AnyOrUnknown */) && !!signature.resolvedReturnType && !!(signature.resolvedReturnType.flags & 16 /* Boolean */);
78191
+ }
78192
+ if (!cache.hasSimpleUnrestrictedSingleCallSignature) {
78193
+ const syntheticCall = createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType);
78194
+ const returnType = getReturnTypeOfSignature(getResolvedSignature(syntheticCall));
78195
+ 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);
78196
+ }
78197
+ }
78198
+ if (!(hasInstanceMethodType || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
78199
+ if (hasGlobalSymbolHasInstanceProperty === void 0) {
78200
+ const globalESSymbolConstructorSymbol = getGlobalESSymbolConstructorTypeSymbol(
78201
+ /*reportErrors*/
78202
+ false
78203
+ );
78204
+ hasGlobalSymbolHasInstanceProperty = !!globalESSymbolConstructorSymbol && getMembersOfSymbol(globalESSymbolConstructorSymbol).has("hasInstance");
78205
+ }
78206
+ 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;
78207
+ error2(right, message);
78208
+ }
78140
78209
  }
78141
78210
  return booleanType;
78142
78211
  }
@@ -78546,11 +78615,6 @@ function createTypeChecker(host) {
78546
78615
  }
78547
78616
  leftType = checkNonNullType(leftType, left);
78548
78617
  rightType = checkNonNullType(rightType, right);
78549
- if (leftType.flags & rightType.flags & 1024 /* EnumLiteral */) {
78550
- if (getBaseTypeOfEnumLikeType(leftType).symbol !== getBaseTypeOfEnumLikeType(rightType).symbol) {
78551
- error2(errorNode, Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations);
78552
- }
78553
- }
78554
78618
  let suggestedOperator;
78555
78619
  if (leftType.flags & 528 /* BooleanLike */ && rightType.flags & 528 /* BooleanLike */ && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== void 0) {
78556
78620
  error2(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
@@ -147404,7 +147468,7 @@ function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, c
147404
147468
  checker.getTypeAtLocation(errorNode).flags & 1 /* Any */;
147405
147469
  }
147406
147470
  function isInsideAwaitableBody(node) {
147407
- return node.kind & 65536 /* AwaitContext */ || !!findAncestor(node, (ancestor) => ancestor.parent && isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || isBlock(ancestor) && (ancestor.parent.kind === 262 /* FunctionDeclaration */ || ancestor.parent.kind === 218 /* FunctionExpression */ || ancestor.parent.kind === 219 /* ArrowFunction */ || ancestor.parent.kind === 174 /* MethodDeclaration */));
147471
+ return node.flags & 65536 /* AwaitContext */ || !!findAncestor(node, (ancestor) => ancestor.parent && isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || isBlock(ancestor) && (ancestor.parent.kind === 262 /* FunctionDeclaration */ || ancestor.parent.kind === 218 /* FunctionExpression */ || ancestor.parent.kind === 219 /* ArrowFunction */ || ancestor.parent.kind === 174 /* MethodDeclaration */));
147408
147472
  }
147409
147473
  function makeChange3(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
147410
147474
  if (isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
@@ -5146,7 +5146,7 @@ declare namespace ts {
5146
5146
  readonly asteriskToken?: AsteriskToken;
5147
5147
  readonly expression?: Expression;
5148
5148
  }
5149
- interface SyntheticExpression extends Expression {
5149
+ interface SyntheticExpression extends LeftHandSideExpression {
5150
5150
  readonly kind: SyntaxKind.SyntheticExpression;
5151
5151
  readonly isSpread: boolean;
5152
5152
  readonly type: Type;
@@ -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;
@@ -46371,6 +46375,7 @@ ${lanes.join("\n")}
46371
46375
  var potentialReflectCollisions = [];
46372
46376
  var potentialUnusedRenamedBindingElementsInTypes = [];
46373
46377
  var awaitedTypeStack = [];
46378
+ var hasGlobalSymbolHasInstanceProperty;
46374
46379
  var diagnostics = createDiagnosticCollection();
46375
46380
  var suggestionDiagnostics = createDiagnosticCollection();
46376
46381
  var typeofType = createTypeofType();
@@ -68449,6 +68454,15 @@ ${lanes.join("\n")}
68449
68454
  return type;
68450
68455
  }
68451
68456
  const rightType = getTypeOfExpression(expr.right);
68457
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
68458
+ if (hasInstanceMethodType) {
68459
+ const syntheticCall = createSyntheticHasInstanceMethodCall(left, expr.right, type, hasInstanceMethodType);
68460
+ const signature = getEffectsSignature(syntheticCall);
68461
+ const predicate = signature && getTypePredicateOfSignature(signature);
68462
+ if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
68463
+ return narrowTypeByTypePredicate(type, predicate, syntheticCall, assumeTrue);
68464
+ }
68465
+ }
68452
68466
  if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
68453
68467
  return type;
68454
68468
  }
@@ -68528,8 +68542,12 @@ ${lanes.join("\n")}
68528
68542
  }
68529
68543
  function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
68530
68544
  if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
68531
- const predicateArgument = getTypePredicateArgument(predicate, callExpression);
68545
+ let predicateArgument = getTypePredicateArgument(predicate, callExpression);
68532
68546
  if (predicateArgument) {
68547
+ if (isSyntheticExpression(predicateArgument) && predicate.parameterIndex === 0 && isSyntheticHasInstanceMethodCall(callExpression)) {
68548
+ Debug.assertNode(predicateArgument.parent, isExpression);
68549
+ predicateArgument = predicateArgument.parent;
68550
+ }
68533
68551
  if (isMatchingReference(reference, predicateArgument)) {
68534
68552
  return getNarrowedType(
68535
68553
  type,
@@ -73105,7 +73123,7 @@ ${lanes.join("\n")}
73105
73123
  }
73106
73124
  return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
73107
73125
  }
73108
- function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessage) {
73126
+ function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessageCallback) {
73109
73127
  const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
73110
73128
  const isDecorator2 = node.kind === 170 /* Decorator */;
73111
73129
  const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
@@ -73148,6 +73166,7 @@ ${lanes.join("\n")}
73148
73166
  chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error);
73149
73167
  chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call);
73150
73168
  }
73169
+ const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
73151
73170
  if (headMessage) {
73152
73171
  chain = chainDiagnosticMessages(chain, headMessage);
73153
73172
  }
@@ -73215,6 +73234,7 @@ ${lanes.join("\n")}
73215
73234
  map(diags, createDiagnosticMessageChainFromDiagnostic),
73216
73235
  Diagnostics.No_overload_matches_this_call
73217
73236
  );
73237
+ const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
73218
73238
  if (headMessage) {
73219
73239
  chain = chainDiagnosticMessages(chain, headMessage);
73220
73240
  }
@@ -73230,21 +73250,21 @@ ${lanes.join("\n")}
73230
73250
  diagnostics.add(diag2);
73231
73251
  }
73232
73252
  } else if (candidateForArgumentArityError) {
73233
- diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessage));
73253
+ diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessageCallback == null ? void 0 : headMessageCallback()));
73234
73254
  } else if (candidateForTypeArgumentError) {
73235
73255
  checkTypeArguments(
73236
73256
  candidateForTypeArgumentError,
73237
73257
  node.typeArguments,
73238
73258
  /*reportErrors*/
73239
73259
  true,
73240
- headMessage
73260
+ headMessageCallback == null ? void 0 : headMessageCallback()
73241
73261
  );
73242
73262
  } else {
73243
73263
  const signaturesWithCorrectTypeArgumentArity = filter(signatures, (s) => hasCorrectTypeArgumentArity(s, typeArguments));
73244
73264
  if (signaturesWithCorrectTypeArgumentArity.length === 0) {
73245
- diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessage));
73265
+ diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessageCallback == null ? void 0 : headMessageCallback()));
73246
73266
  } else {
73247
- diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessage));
73267
+ diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessageCallback == null ? void 0 : headMessageCallback()));
73248
73268
  }
73249
73269
  }
73250
73270
  }
@@ -73552,7 +73572,7 @@ ${lanes.join("\n")}
73552
73572
  error2(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
73553
73573
  return resolveErrorCall(node);
73554
73574
  }
73555
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
73575
+ 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);
73556
73576
  }
73557
73577
  function isGenericFunctionReturningFunction(signature) {
73558
73578
  return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@@ -73849,7 +73869,7 @@ ${lanes.join("\n")}
73849
73869
  invocationErrorRecovery(apparentType, 0 /* Call */, diag2);
73850
73870
  return resolveErrorCall(node);
73851
73871
  }
73852
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
73872
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, () => headMessage);
73853
73873
  }
73854
73874
  function createSignatureForJSXIntrinsic(node, result) {
73855
73875
  const namespace = getJsxNamespaceAt(node);
@@ -75891,6 +75911,32 @@ ${lanes.join("\n")}
75891
75911
  function isConstEnumSymbol(symbol) {
75892
75912
  return (symbol.flags & 128 /* ConstEnum */) !== 0;
75893
75913
  }
75914
+ function getSymbolHasInstanceMethodOfObjectType(type) {
75915
+ const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
75916
+ const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
75917
+ if (hasInstanceProperty) {
75918
+ const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
75919
+ if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
75920
+ return hasInstancePropertyType;
75921
+ }
75922
+ }
75923
+ }
75924
+ function createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType) {
75925
+ const syntheticExpression = createSyntheticExpression(right, hasInstanceMethodType);
75926
+ const syntheticArgument = createSyntheticExpression(left, leftType);
75927
+ const syntheticCall = parseNodeFactory.createCallExpression(
75928
+ syntheticExpression,
75929
+ /*typeArguments*/
75930
+ void 0,
75931
+ [syntheticArgument]
75932
+ );
75933
+ setParent(syntheticCall, left.parent);
75934
+ setTextRange(syntheticCall, left.parent);
75935
+ return syntheticCall;
75936
+ }
75937
+ function isSyntheticHasInstanceMethodCall(node) {
75938
+ 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;
75939
+ }
75894
75940
  function checkInstanceOfExpression(left, right, leftType, rightType) {
75895
75941
  if (leftType === silentNeverType || rightType === silentNeverType) {
75896
75942
  return silentNeverType;
@@ -75898,8 +75944,31 @@ ${lanes.join("\n")}
75898
75944
  if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
75899
75945
  error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
75900
75946
  }
75901
- if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
75902
- error2(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);
75947
+ if (!isTypeAny(rightType)) {
75948
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
75949
+ if (hasInstanceMethodType) {
75950
+ const cache = hasInstanceMethodType;
75951
+ if (cache.hasSimpleUnrestrictedSingleCallSignature === void 0) {
75952
+ const signature = getSingleCallSignature(hasInstanceMethodType);
75953
+ cache.hasSimpleUnrestrictedSingleCallSignature = !!signature && signature.parameters.length === 1 && !!(getTypeOfSymbol(signature.parameters[0]).flags & 3 /* AnyOrUnknown */) && !!signature.resolvedReturnType && !!(signature.resolvedReturnType.flags & 16 /* Boolean */);
75954
+ }
75955
+ if (!cache.hasSimpleUnrestrictedSingleCallSignature) {
75956
+ const syntheticCall = createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType);
75957
+ const returnType = getReturnTypeOfSignature(getResolvedSignature(syntheticCall));
75958
+ 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);
75959
+ }
75960
+ }
75961
+ if (!(hasInstanceMethodType || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
75962
+ if (hasGlobalSymbolHasInstanceProperty === void 0) {
75963
+ const globalESSymbolConstructorSymbol = getGlobalESSymbolConstructorTypeSymbol(
75964
+ /*reportErrors*/
75965
+ false
75966
+ );
75967
+ hasGlobalSymbolHasInstanceProperty = !!globalESSymbolConstructorSymbol && getMembersOfSymbol(globalESSymbolConstructorSymbol).has("hasInstance");
75968
+ }
75969
+ 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;
75970
+ error2(right, message);
75971
+ }
75903
75972
  }
75904
75973
  return booleanType;
75905
75974
  }
@@ -76309,11 +76378,6 @@ ${lanes.join("\n")}
76309
76378
  }
76310
76379
  leftType = checkNonNullType(leftType, left);
76311
76380
  rightType = checkNonNullType(rightType, right);
76312
- if (leftType.flags & rightType.flags & 1024 /* EnumLiteral */) {
76313
- if (getBaseTypeOfEnumLikeType(leftType).symbol !== getBaseTypeOfEnumLikeType(rightType).symbol) {
76314
- error2(errorNode, Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations);
76315
- }
76316
- }
76317
76381
  let suggestedOperator;
76318
76382
  if (leftType.flags & 528 /* BooleanLike */ && rightType.flags & 528 /* BooleanLike */ && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== void 0) {
76319
76383
  error2(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
@@ -146001,7 +146065,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
146001
146065
  checker.getTypeAtLocation(errorNode).flags & 1 /* Any */;
146002
146066
  }
146003
146067
  function isInsideAwaitableBody(node) {
146004
- return node.kind & 65536 /* AwaitContext */ || !!findAncestor(node, (ancestor) => ancestor.parent && isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || isBlock(ancestor) && (ancestor.parent.kind === 262 /* FunctionDeclaration */ || ancestor.parent.kind === 218 /* FunctionExpression */ || ancestor.parent.kind === 219 /* ArrowFunction */ || ancestor.parent.kind === 174 /* MethodDeclaration */));
146068
+ return node.flags & 65536 /* AwaitContext */ || !!findAncestor(node, (ancestor) => ancestor.parent && isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || isBlock(ancestor) && (ancestor.parent.kind === 262 /* FunctionDeclaration */ || ancestor.parent.kind === 218 /* FunctionExpression */ || ancestor.parent.kind === 219 /* ArrowFunction */ || ancestor.parent.kind === 174 /* MethodDeclaration */));
146005
146069
  }
146006
146070
  function makeChange3(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
146007
146071
  if (isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
@@ -1086,7 +1086,7 @@ declare namespace ts {
1086
1086
  readonly asteriskToken?: AsteriskToken;
1087
1087
  readonly expression?: Expression;
1088
1088
  }
1089
- interface SyntheticExpression extends Expression {
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;
@@ -46371,6 +46375,7 @@ ${lanes.join("\n")}
46371
46375
  var potentialReflectCollisions = [];
46372
46376
  var potentialUnusedRenamedBindingElementsInTypes = [];
46373
46377
  var awaitedTypeStack = [];
46378
+ var hasGlobalSymbolHasInstanceProperty;
46374
46379
  var diagnostics = createDiagnosticCollection();
46375
46380
  var suggestionDiagnostics = createDiagnosticCollection();
46376
46381
  var typeofType = createTypeofType();
@@ -68449,6 +68454,15 @@ ${lanes.join("\n")}
68449
68454
  return type;
68450
68455
  }
68451
68456
  const rightType = getTypeOfExpression(expr.right);
68457
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
68458
+ if (hasInstanceMethodType) {
68459
+ const syntheticCall = createSyntheticHasInstanceMethodCall(left, expr.right, type, hasInstanceMethodType);
68460
+ const signature = getEffectsSignature(syntheticCall);
68461
+ const predicate = signature && getTypePredicateOfSignature(signature);
68462
+ if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
68463
+ return narrowTypeByTypePredicate(type, predicate, syntheticCall, assumeTrue);
68464
+ }
68465
+ }
68452
68466
  if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
68453
68467
  return type;
68454
68468
  }
@@ -68528,8 +68542,12 @@ ${lanes.join("\n")}
68528
68542
  }
68529
68543
  function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
68530
68544
  if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
68531
- const predicateArgument = getTypePredicateArgument(predicate, callExpression);
68545
+ let predicateArgument = getTypePredicateArgument(predicate, callExpression);
68532
68546
  if (predicateArgument) {
68547
+ if (isSyntheticExpression(predicateArgument) && predicate.parameterIndex === 0 && isSyntheticHasInstanceMethodCall(callExpression)) {
68548
+ Debug.assertNode(predicateArgument.parent, isExpression);
68549
+ predicateArgument = predicateArgument.parent;
68550
+ }
68533
68551
  if (isMatchingReference(reference, predicateArgument)) {
68534
68552
  return getNarrowedType(
68535
68553
  type,
@@ -73105,7 +73123,7 @@ ${lanes.join("\n")}
73105
73123
  }
73106
73124
  return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
73107
73125
  }
73108
- function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessage) {
73126
+ function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessageCallback) {
73109
73127
  const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
73110
73128
  const isDecorator2 = node.kind === 170 /* Decorator */;
73111
73129
  const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
@@ -73148,6 +73166,7 @@ ${lanes.join("\n")}
73148
73166
  chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error);
73149
73167
  chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call);
73150
73168
  }
73169
+ const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
73151
73170
  if (headMessage) {
73152
73171
  chain = chainDiagnosticMessages(chain, headMessage);
73153
73172
  }
@@ -73215,6 +73234,7 @@ ${lanes.join("\n")}
73215
73234
  map(diags, createDiagnosticMessageChainFromDiagnostic),
73216
73235
  Diagnostics.No_overload_matches_this_call
73217
73236
  );
73237
+ const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
73218
73238
  if (headMessage) {
73219
73239
  chain = chainDiagnosticMessages(chain, headMessage);
73220
73240
  }
@@ -73230,21 +73250,21 @@ ${lanes.join("\n")}
73230
73250
  diagnostics.add(diag2);
73231
73251
  }
73232
73252
  } else if (candidateForArgumentArityError) {
73233
- diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessage));
73253
+ diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessageCallback == null ? void 0 : headMessageCallback()));
73234
73254
  } else if (candidateForTypeArgumentError) {
73235
73255
  checkTypeArguments(
73236
73256
  candidateForTypeArgumentError,
73237
73257
  node.typeArguments,
73238
73258
  /*reportErrors*/
73239
73259
  true,
73240
- headMessage
73260
+ headMessageCallback == null ? void 0 : headMessageCallback()
73241
73261
  );
73242
73262
  } else {
73243
73263
  const signaturesWithCorrectTypeArgumentArity = filter(signatures, (s) => hasCorrectTypeArgumentArity(s, typeArguments));
73244
73264
  if (signaturesWithCorrectTypeArgumentArity.length === 0) {
73245
- diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessage));
73265
+ diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessageCallback == null ? void 0 : headMessageCallback()));
73246
73266
  } else {
73247
- diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessage));
73267
+ diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessageCallback == null ? void 0 : headMessageCallback()));
73248
73268
  }
73249
73269
  }
73250
73270
  }
@@ -73552,7 +73572,7 @@ ${lanes.join("\n")}
73552
73572
  error2(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
73553
73573
  return resolveErrorCall(node);
73554
73574
  }
73555
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
73575
+ 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);
73556
73576
  }
73557
73577
  function isGenericFunctionReturningFunction(signature) {
73558
73578
  return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@@ -73849,7 +73869,7 @@ ${lanes.join("\n")}
73849
73869
  invocationErrorRecovery(apparentType, 0 /* Call */, diag2);
73850
73870
  return resolveErrorCall(node);
73851
73871
  }
73852
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
73872
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, () => headMessage);
73853
73873
  }
73854
73874
  function createSignatureForJSXIntrinsic(node, result) {
73855
73875
  const namespace = getJsxNamespaceAt(node);
@@ -75891,6 +75911,32 @@ ${lanes.join("\n")}
75891
75911
  function isConstEnumSymbol(symbol) {
75892
75912
  return (symbol.flags & 128 /* ConstEnum */) !== 0;
75893
75913
  }
75914
+ function getSymbolHasInstanceMethodOfObjectType(type) {
75915
+ const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
75916
+ const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
75917
+ if (hasInstanceProperty) {
75918
+ const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
75919
+ if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
75920
+ return hasInstancePropertyType;
75921
+ }
75922
+ }
75923
+ }
75924
+ function createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType) {
75925
+ const syntheticExpression = createSyntheticExpression(right, hasInstanceMethodType);
75926
+ const syntheticArgument = createSyntheticExpression(left, leftType);
75927
+ const syntheticCall = parseNodeFactory.createCallExpression(
75928
+ syntheticExpression,
75929
+ /*typeArguments*/
75930
+ void 0,
75931
+ [syntheticArgument]
75932
+ );
75933
+ setParent(syntheticCall, left.parent);
75934
+ setTextRange(syntheticCall, left.parent);
75935
+ return syntheticCall;
75936
+ }
75937
+ function isSyntheticHasInstanceMethodCall(node) {
75938
+ 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;
75939
+ }
75894
75940
  function checkInstanceOfExpression(left, right, leftType, rightType) {
75895
75941
  if (leftType === silentNeverType || rightType === silentNeverType) {
75896
75942
  return silentNeverType;
@@ -75898,8 +75944,31 @@ ${lanes.join("\n")}
75898
75944
  if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
75899
75945
  error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
75900
75946
  }
75901
- if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
75902
- error2(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);
75947
+ if (!isTypeAny(rightType)) {
75948
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
75949
+ if (hasInstanceMethodType) {
75950
+ const cache = hasInstanceMethodType;
75951
+ if (cache.hasSimpleUnrestrictedSingleCallSignature === void 0) {
75952
+ const signature = getSingleCallSignature(hasInstanceMethodType);
75953
+ cache.hasSimpleUnrestrictedSingleCallSignature = !!signature && signature.parameters.length === 1 && !!(getTypeOfSymbol(signature.parameters[0]).flags & 3 /* AnyOrUnknown */) && !!signature.resolvedReturnType && !!(signature.resolvedReturnType.flags & 16 /* Boolean */);
75954
+ }
75955
+ if (!cache.hasSimpleUnrestrictedSingleCallSignature) {
75956
+ const syntheticCall = createSyntheticHasInstanceMethodCall(left, right, leftType, hasInstanceMethodType);
75957
+ const returnType = getReturnTypeOfSignature(getResolvedSignature(syntheticCall));
75958
+ 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);
75959
+ }
75960
+ }
75961
+ if (!(hasInstanceMethodType || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
75962
+ if (hasGlobalSymbolHasInstanceProperty === void 0) {
75963
+ const globalESSymbolConstructorSymbol = getGlobalESSymbolConstructorTypeSymbol(
75964
+ /*reportErrors*/
75965
+ false
75966
+ );
75967
+ hasGlobalSymbolHasInstanceProperty = !!globalESSymbolConstructorSymbol && getMembersOfSymbol(globalESSymbolConstructorSymbol).has("hasInstance");
75968
+ }
75969
+ 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;
75970
+ error2(right, message);
75971
+ }
75903
75972
  }
75904
75973
  return booleanType;
75905
75974
  }
@@ -76309,11 +76378,6 @@ ${lanes.join("\n")}
76309
76378
  }
76310
76379
  leftType = checkNonNullType(leftType, left);
76311
76380
  rightType = checkNonNullType(rightType, right);
76312
- if (leftType.flags & rightType.flags & 1024 /* EnumLiteral */) {
76313
- if (getBaseTypeOfEnumLikeType(leftType).symbol !== getBaseTypeOfEnumLikeType(rightType).symbol) {
76314
- error2(errorNode, Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations);
76315
- }
76316
- }
76317
76381
  let suggestedOperator;
76318
76382
  if (leftType.flags & 528 /* BooleanLike */ && rightType.flags & 528 /* BooleanLike */ && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== void 0) {
76319
76383
  error2(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
@@ -146016,7 +146080,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
146016
146080
  checker.getTypeAtLocation(errorNode).flags & 1 /* Any */;
146017
146081
  }
146018
146082
  function isInsideAwaitableBody(node) {
146019
- return node.kind & 65536 /* AwaitContext */ || !!findAncestor(node, (ancestor) => ancestor.parent && isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || isBlock(ancestor) && (ancestor.parent.kind === 262 /* FunctionDeclaration */ || ancestor.parent.kind === 218 /* FunctionExpression */ || ancestor.parent.kind === 219 /* ArrowFunction */ || ancestor.parent.kind === 174 /* MethodDeclaration */));
146083
+ return node.flags & 65536 /* AwaitContext */ || !!findAncestor(node, (ancestor) => ancestor.parent && isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || isBlock(ancestor) && (ancestor.parent.kind === 262 /* FunctionDeclaration */ || ancestor.parent.kind === 218 /* FunctionExpression */ || ancestor.parent.kind === 219 /* ArrowFunction */ || ancestor.parent.kind === 174 /* MethodDeclaration */));
146020
146084
  }
146021
146085
  function makeChange3(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
146022
146086
  if (isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
@@ -6044,6 +6044,9 @@ var Diagnostics = {
6044
6044
  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."),
6045
6045
  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."),
6046
6046
  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."),
6047
+ 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."),
6048
+ 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."),
6049
+ 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."),
6047
6050
  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}'."),
6048
6051
  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}'."),
6049
6052
  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}'."),
@@ -9873,6 +9876,7 @@ function isLeftHandSideExpressionKind(kind) {
9873
9876
  case 236 /* MetaProperty */:
9874
9877
  case 102 /* ImportKeyword */:
9875
9878
  case 282 /* MissingDeclaration */:
9879
+ case 237 /* SyntheticExpression */:
9876
9880
  return true;
9877
9881
  default:
9878
9882
  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.3.0-pr-55319-8",
5
+ "version": "5.3.0-pr-55052-14",
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": "3a65f1f67de93b8700b318854af93cf1821e9489"
117
+ "gitHead": "806962222f223687096ac6971a954ae54533556b"
118
118
  }