@typescript-deploys/pr-build 5.3.0-pr-55052-14 → 5.3.0-pr-55109-10

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/tsserver.js CHANGED
@@ -2331,7 +2331,7 @@ module.exports = __toCommonJS(server_exports);
2331
2331
 
2332
2332
  // src/compiler/corePublic.ts
2333
2333
  var versionMajorMinor = "5.3";
2334
- var version = `${versionMajorMinor}.0-insiders.20230809`;
2334
+ var version = `${versionMajorMinor}.0-insiders.20230810`;
2335
2335
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2336
2336
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2337
2337
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -10193,9 +10193,6 @@ 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."),
10199
10196
  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}'."),
10200
10197
  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}'."),
10201
10198
  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}'."),
@@ -11037,6 +11034,7 @@ var Diagnostics = {
11037
11034
  Unknown_type_acquisition_option_0_Did_you_mean_1: diag(17018, 1 /* Error */, "Unknown_type_acquisition_option_0_Did_you_mean_1_17018", "Unknown type acquisition option '{0}'. Did you mean '{1}'?"),
11038
11035
  _0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1: diag(17019, 1 /* Error */, "_0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1_17019", "'{0}' at the end of a type is not valid TypeScript syntax. Did you mean to write '{1}'?"),
11039
11036
  _0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1: diag(17020, 1 /* Error */, "_0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1_17020", "'{0}' at the start of a type is not valid TypeScript syntax. Did you mean to write '{1}'?"),
11037
+ Unicode_escape_sequence_cannot_appear_here: diag(17021, 1 /* Error */, "Unicode_escape_sequence_cannot_appear_here_17021", "Unicode escape sequence cannot appear here."),
11040
11038
  Circularity_detected_while_resolving_configuration_Colon_0: diag(18e3, 1 /* Error */, "Circularity_detected_while_resolving_configuration_Colon_0_18000", "Circularity detected while resolving configuration: {0}"),
11041
11039
  The_files_list_in_config_file_0_is_empty: diag(18002, 1 /* Error */, "The_files_list_in_config_file_0_is_empty_18002", "The 'files' list in config file '{0}' is empty."),
11042
11040
  No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: diag(18003, 1 /* Error */, "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'."),
@@ -14669,7 +14667,6 @@ function isLeftHandSideExpressionKind(kind) {
14669
14667
  case 236 /* MetaProperty */:
14670
14668
  case 102 /* ImportKeyword */:
14671
14669
  case 282 /* MissingDeclaration */:
14672
- case 237 /* SyntheticExpression */:
14673
14670
  return true;
14674
14671
  default:
14675
14672
  return false;
@@ -31677,6 +31674,12 @@ var Parser;
31677
31674
  function parseIdentifierName(diagnosticMessage) {
31678
31675
  return createIdentifier(tokenIsIdentifierOrKeyword(token()), diagnosticMessage);
31679
31676
  }
31677
+ function parseIdentifierNameErrorOnUnicodeEscapeSequence() {
31678
+ if (scanner2.hasUnicodeEscape() || scanner2.hasExtendedUnicodeEscape()) {
31679
+ parseErrorAtCurrentToken(Diagnostics.Unicode_escape_sequence_cannot_appear_here);
31680
+ }
31681
+ return createIdentifier(tokenIsIdentifierOrKeyword(token()));
31682
+ }
31680
31683
  function isLiteralPropertyName() {
31681
31684
  return tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */ || token() === 9 /* NumericLiteral */;
31682
31685
  }
@@ -32303,7 +32306,9 @@ var Parser;
32303
32306
  parseRightSideOfDot(
32304
32307
  allowReservedWords,
32305
32308
  /*allowPrivateIdentifiers*/
32306
- false
32309
+ false,
32310
+ /*allowUnicodeEscapeSequenceInIdentifierName*/
32311
+ true
32307
32312
  )
32308
32313
  ),
32309
32314
  pos
@@ -32314,7 +32319,7 @@ var Parser;
32314
32319
  function createQualifiedName(entity, name) {
32315
32320
  return finishNode(factory2.createQualifiedName(entity, name), entity.pos);
32316
32321
  }
32317
- function parseRightSideOfDot(allowIdentifierNames, allowPrivateIdentifiers) {
32322
+ function parseRightSideOfDot(allowIdentifierNames, allowPrivateIdentifiers, allowUnicodeEscapeSequenceInIdentifierName) {
32318
32323
  if (scanner2.hasPrecedingLineBreak() && tokenIsIdentifierOrKeyword(token())) {
32319
32324
  const matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
32320
32325
  if (matchesPattern) {
@@ -32335,7 +32340,10 @@ var Parser;
32335
32340
  Diagnostics.Identifier_expected
32336
32341
  );
32337
32342
  }
32338
- return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
32343
+ if (allowIdentifierNames) {
32344
+ return allowUnicodeEscapeSequenceInIdentifierName ? parseIdentifierName() : parseIdentifierNameErrorOnUnicodeEscapeSequence();
32345
+ }
32346
+ return parseIdentifier();
32339
32347
  }
32340
32348
  function parseTemplateSpans(isTaggedTemplate) {
32341
32349
  const pos = getNodePos();
@@ -34110,6 +34118,8 @@ var Parser;
34110
34118
  /*allowIdentifierNames*/
34111
34119
  true,
34112
34120
  /*allowPrivateIdentifiers*/
34121
+ true,
34122
+ /*allowUnicodeEscapeSequenceInIdentifierName*/
34113
34123
  true
34114
34124
  )), pos);
34115
34125
  }
@@ -34277,6 +34287,8 @@ var Parser;
34277
34287
  /*allowIdentifierNames*/
34278
34288
  true,
34279
34289
  /*allowPrivateIdentifiers*/
34290
+ false,
34291
+ /*allowUnicodeEscapeSequenceInIdentifierName*/
34280
34292
  false
34281
34293
  )), pos);
34282
34294
  }
@@ -34286,10 +34298,10 @@ var Parser;
34286
34298
  const pos = getNodePos();
34287
34299
  scanJsxIdentifier();
34288
34300
  const isThis2 = token() === 110 /* ThisKeyword */;
34289
- const tagName = parseIdentifierName();
34301
+ const tagName = parseIdentifierNameErrorOnUnicodeEscapeSequence();
34290
34302
  if (parseOptional(59 /* ColonToken */)) {
34291
34303
  scanJsxIdentifier();
34292
- return finishNode(factory2.createJsxNamespacedName(tagName, parseIdentifierName()), pos);
34304
+ return finishNode(factory2.createJsxNamespacedName(tagName, parseIdentifierNameErrorOnUnicodeEscapeSequence()), pos);
34293
34305
  }
34294
34306
  return isThis2 ? finishNode(factory2.createToken(110 /* ThisKeyword */), pos) : tagName;
34295
34307
  }
@@ -34350,10 +34362,10 @@ var Parser;
34350
34362
  function parseJsxAttributeName() {
34351
34363
  const pos = getNodePos();
34352
34364
  scanJsxIdentifier();
34353
- const attrName = parseIdentifierName();
34365
+ const attrName = parseIdentifierNameErrorOnUnicodeEscapeSequence();
34354
34366
  if (parseOptional(59 /* ColonToken */)) {
34355
34367
  scanJsxIdentifier();
34356
- return finishNode(factory2.createJsxNamespacedName(attrName, parseIdentifierName()), pos);
34368
+ return finishNode(factory2.createJsxNamespacedName(attrName, parseIdentifierNameErrorOnUnicodeEscapeSequence()), pos);
34357
34369
  }
34358
34370
  return attrName;
34359
34371
  }
@@ -34441,6 +34453,8 @@ var Parser;
34441
34453
  /*allowIdentifierNames*/
34442
34454
  true,
34443
34455
  /*allowPrivateIdentifiers*/
34456
+ true,
34457
+ /*allowUnicodeEscapeSequenceInIdentifierName*/
34444
34458
  true
34445
34459
  );
34446
34460
  const isOptionalChain2 = questionDotToken || tryReparseOptionalChain(expression);
@@ -48612,7 +48626,6 @@ function createTypeChecker(host) {
48612
48626
  var potentialReflectCollisions = [];
48613
48627
  var potentialUnusedRenamedBindingElementsInTypes = [];
48614
48628
  var awaitedTypeStack = [];
48615
- var hasGlobalSymbolHasInstanceProperty;
48616
48629
  var diagnostics = createDiagnosticCollection();
48617
48630
  var suggestionDiagnostics = createDiagnosticCollection();
48618
48631
  var typeofType = createTypeofType();
@@ -61232,7 +61245,10 @@ function createTypeChecker(host) {
61232
61245
  }
61233
61246
  }
61234
61247
  function removeStringLiteralsMatchedByTemplateLiterals(types) {
61235
- const templates = filter(types, (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t));
61248
+ const templates = filter(
61249
+ types,
61250
+ (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t) && t.types.every((t2) => !(t2.flags & 2097152 /* Intersection */) || !areIntersectedTypesAvoidingPrimitiveReduction(t2.types))
61251
+ );
61236
61252
  if (templates.length) {
61237
61253
  let i = types.length;
61238
61254
  while (i > 0) {
@@ -61637,15 +61653,19 @@ function createTypeChecker(host) {
61637
61653
  function getConstituentCountOfTypes(types) {
61638
61654
  return reduceLeft(types, (n, t) => n + getConstituentCount(t), 0);
61639
61655
  }
61640
- function areIntersectedTypesAvoidingPrimitiveReduction(t1, t2) {
61641
- return !!(t1.flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && t2 === emptyTypeLiteralType;
61656
+ function areIntersectedTypesAvoidingPrimitiveReduction(types, primitiveFlags = 4 /* String */ | 8 /* Number */ | 64 /* BigInt */) {
61657
+ if (types.length !== 2) {
61658
+ return false;
61659
+ }
61660
+ const [t1, t2] = types;
61661
+ return !!(t1.flags & primitiveFlags) && t2 === emptyTypeLiteralType || !!(t2.flags & primitiveFlags) && t1 === emptyTypeLiteralType;
61642
61662
  }
61643
61663
  function getTypeFromIntersectionTypeNode(node) {
61644
61664
  const links = getNodeLinks(node);
61645
61665
  if (!links.resolvedType) {
61646
61666
  const aliasSymbol = getAliasSymbolForTypeNode(node);
61647
61667
  const types = map(node.types, getTypeFromTypeNode);
61648
- const noSupertypeReduction = types.length === 2 && (areIntersectedTypesAvoidingPrimitiveReduction(types[0], types[1]) || areIntersectedTypesAvoidingPrimitiveReduction(types[1], types[0]));
61668
+ const noSupertypeReduction = areIntersectedTypesAvoidingPrimitiveReduction(types);
61649
61669
  links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
61650
61670
  }
61651
61671
  return links.resolvedType;
@@ -68103,6 +68123,9 @@ function createTypeChecker(host) {
68103
68123
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
68104
68124
  return true;
68105
68125
  }
68126
+ if (target.flags & 2097152 /* Intersection */) {
68127
+ return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
68128
+ }
68106
68129
  if (source.flags & 128 /* StringLiteral */) {
68107
68130
  const value = source.value;
68108
68131
  return !!(target.flags & 8 /* Number */ && isValidNumberString(
@@ -68113,7 +68136,7 @@ function createTypeChecker(host) {
68113
68136
  value,
68114
68137
  /*roundTripOnly*/
68115
68138
  false
68116
- ) || target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName || target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
68139
+ ) || target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName || target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target) || target.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source, target));
68117
68140
  }
68118
68141
  if (source.flags & 134217728 /* TemplateLiteral */) {
68119
68142
  const texts = source.texts;
@@ -70691,15 +70714,6 @@ function createTypeChecker(host) {
70691
70714
  return type;
70692
70715
  }
70693
70716
  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
- }
70703
70717
  if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
70704
70718
  return type;
70705
70719
  }
@@ -70779,12 +70793,8 @@ function createTypeChecker(host) {
70779
70793
  }
70780
70794
  function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
70781
70795
  if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
70782
- let predicateArgument = getTypePredicateArgument(predicate, callExpression);
70796
+ const predicateArgument = getTypePredicateArgument(predicate, callExpression);
70783
70797
  if (predicateArgument) {
70784
- if (isSyntheticExpression(predicateArgument) && predicate.parameterIndex === 0 && isSyntheticHasInstanceMethodCall(callExpression)) {
70785
- Debug.assertNode(predicateArgument.parent, isExpression);
70786
- predicateArgument = predicateArgument.parent;
70787
- }
70788
70798
  if (isMatchingReference(reference, predicateArgument)) {
70789
70799
  return getNarrowedType(
70790
70800
  type,
@@ -75360,7 +75370,7 @@ function createTypeChecker(host) {
75360
75370
  }
75361
75371
  return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
75362
75372
  }
75363
- function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessageCallback) {
75373
+ function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, headMessage) {
75364
75374
  const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
75365
75375
  const isDecorator2 = node.kind === 170 /* Decorator */;
75366
75376
  const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
@@ -75403,7 +75413,6 @@ function createTypeChecker(host) {
75403
75413
  chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error);
75404
75414
  chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call);
75405
75415
  }
75406
- const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
75407
75416
  if (headMessage) {
75408
75417
  chain = chainDiagnosticMessages(chain, headMessage);
75409
75418
  }
@@ -75471,7 +75480,6 @@ function createTypeChecker(host) {
75471
75480
  map(diags, createDiagnosticMessageChainFromDiagnostic),
75472
75481
  Diagnostics.No_overload_matches_this_call
75473
75482
  );
75474
- const headMessage = headMessageCallback == null ? void 0 : headMessageCallback();
75475
75483
  if (headMessage) {
75476
75484
  chain = chainDiagnosticMessages(chain, headMessage);
75477
75485
  }
@@ -75487,21 +75495,21 @@ function createTypeChecker(host) {
75487
75495
  diagnostics.add(diag2);
75488
75496
  }
75489
75497
  } else if (candidateForArgumentArityError) {
75490
- diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessageCallback == null ? void 0 : headMessageCallback()));
75498
+ diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args, headMessage));
75491
75499
  } else if (candidateForTypeArgumentError) {
75492
75500
  checkTypeArguments(
75493
75501
  candidateForTypeArgumentError,
75494
75502
  node.typeArguments,
75495
75503
  /*reportErrors*/
75496
75504
  true,
75497
- headMessageCallback == null ? void 0 : headMessageCallback()
75505
+ headMessage
75498
75506
  );
75499
75507
  } else {
75500
75508
  const signaturesWithCorrectTypeArgumentArity = filter(signatures, (s) => hasCorrectTypeArgumentArity(s, typeArguments));
75501
75509
  if (signaturesWithCorrectTypeArgumentArity.length === 0) {
75502
- diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessageCallback == null ? void 0 : headMessageCallback()));
75510
+ diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessage));
75503
75511
  } else {
75504
- diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessageCallback == null ? void 0 : headMessageCallback()));
75512
+ diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args, headMessage));
75505
75513
  }
75506
75514
  }
75507
75515
  }
@@ -75809,7 +75817,7 @@ function createTypeChecker(host) {
75809
75817
  error2(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
75810
75818
  return resolveErrorCall(node);
75811
75819
  }
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);
75820
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
75813
75821
  }
75814
75822
  function isGenericFunctionReturningFunction(signature) {
75815
75823
  return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@@ -76106,7 +76114,7 @@ function createTypeChecker(host) {
76106
76114
  invocationErrorRecovery(apparentType, 0 /* Call */, diag2);
76107
76115
  return resolveErrorCall(node);
76108
76116
  }
76109
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, () => headMessage);
76117
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
76110
76118
  }
76111
76119
  function createSignatureForJSXIntrinsic(node, result) {
76112
76120
  const namespace = getJsxNamespaceAt(node);
@@ -78148,32 +78156,6 @@ function createTypeChecker(host) {
78148
78156
  function isConstEnumSymbol(symbol) {
78149
78157
  return (symbol.flags & 128 /* ConstEnum */) !== 0;
78150
78158
  }
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
- }
78177
78159
  function checkInstanceOfExpression(left, right, leftType, rightType) {
78178
78160
  if (leftType === silentNeverType || rightType === silentNeverType) {
78179
78161
  return silentNeverType;
@@ -78181,31 +78163,8 @@ function createTypeChecker(host) {
78181
78163
  if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
78182
78164
  error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
78183
78165
  }
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
- }
78166
+ if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
78167
+ 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);
78209
78168
  }
78210
78169
  return booleanType;
78211
78170
  }
@@ -115592,7 +115551,11 @@ function createPrinter(printerOptions = {}, handlers = {}) {
115592
115551
  function emitMethodSignature(node) {
115593
115552
  pushNameGenerationScope(node);
115594
115553
  emitModifierList(node, node.modifiers);
115595
- emit(node.name);
115554
+ if (node.name.kind === 80 /* Identifier */ && node.name.escapedText === "new") {
115555
+ emit(factory.createStringLiteralFromNode(node.name));
115556
+ } else {
115557
+ emit(node.name);
115558
+ }
115596
115559
  emit(node.questionToken);
115597
115560
  emitTypeParameters(node, node.typeParameters);
115598
115561
  emitParameters(node, node.parameters);
@@ -5146,7 +5146,7 @@ declare namespace ts {
5146
5146
  readonly asteriskToken?: AsteriskToken;
5147
5147
  readonly expression?: Expression;
5148
5148
  }
5149
- interface SyntheticExpression extends LeftHandSideExpression {
5149
+ interface SyntheticExpression extends Expression {
5150
5150
  readonly kind: SyntaxKind.SyntheticExpression;
5151
5151
  readonly isSpread: boolean;
5152
5152
  readonly type: Type;