typescript 5.3.0-dev.20230929 → 5.3.0-dev.20230930

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
@@ -1253,7 +1253,7 @@ __export(server_exports, {
1253
1253
  isClassDeclaration: () => isClassDeclaration,
1254
1254
  isClassElement: () => isClassElement,
1255
1255
  isClassExpression: () => isClassExpression,
1256
- isClassFieldAndNotAutoAccessor: () => isClassFieldAndNotAutoAccessor,
1256
+ isClassInstanceProperty: () => isClassInstanceProperty,
1257
1257
  isClassLike: () => isClassLike,
1258
1258
  isClassMemberModifier: () => isClassMemberModifier,
1259
1259
  isClassNamedEvaluationHelperBlock: () => isClassNamedEvaluationHelperBlock,
@@ -1444,6 +1444,7 @@ __export(server_exports, {
1444
1444
  isInsideJsxElementOrAttribute: () => isInsideJsxElementOrAttribute,
1445
1445
  isInsideNodeModules: () => isInsideNodeModules,
1446
1446
  isInsideTemplateLiteral: () => isInsideTemplateLiteral,
1447
+ isInstanceOfExpression: () => isInstanceOfExpression,
1447
1448
  isInstantiatedModule: () => isInstantiatedModule,
1448
1449
  isInterfaceDeclaration: () => isInterfaceDeclaration,
1449
1450
  isInternalDeclaration: () => isInternalDeclaration,
@@ -1701,6 +1702,7 @@ __export(server_exports, {
1701
1702
  isReturnStatement: () => isReturnStatement,
1702
1703
  isReturnStatementWithFixablePromiseHandler: () => isReturnStatementWithFixablePromiseHandler,
1703
1704
  isRightSideOfAccessExpression: () => isRightSideOfAccessExpression,
1705
+ isRightSideOfInstanceofExpression: () => isRightSideOfInstanceofExpression,
1704
1706
  isRightSideOfPropertyAccess: () => isRightSideOfPropertyAccess,
1705
1707
  isRightSideOfQualifiedName: () => isRightSideOfQualifiedName,
1706
1708
  isRightSideOfQualifiedNameOrPropertyAccess: () => isRightSideOfQualifiedNameOrPropertyAccess,
@@ -2326,7 +2328,7 @@ module.exports = __toCommonJS(server_exports);
2326
2328
 
2327
2329
  // src/compiler/corePublic.ts
2328
2330
  var versionMajorMinor = "5.3";
2329
- var version = `${versionMajorMinor}.0-dev.20230929`;
2331
+ var version = `${versionMajorMinor}.0-dev.20230930`;
2330
2332
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2331
2333
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2332
2334
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -9728,7 +9730,7 @@ var Diagnostics = {
9728
9730
  An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
9729
9731
  The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
9730
9732
  The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
9731
- The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
9733
+ The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_type_assignable_to_the_Function_interface_type_or_an_object_type_with_a_Symbol_hasInstance_method: diag(2359, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_2359", "The right-hand side of an 'instanceof' expression must be either of type 'any', a class, function, or other type assignable to the 'Function' interface type, or an object type with a 'Symbol.hasInstance' method."),
9732
9734
  The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, 1 /* Error */, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
9733
9735
  The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, 1 /* Error */, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
9734
9736
  The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, 1 /* Error */, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."),
@@ -10177,6 +10179,8 @@ var Diagnostics = {
10177
10179
  Import_attributes_cannot_be_used_with_type_only_imports_or_exports: diag(2857, 1 /* Error */, "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857", "Import attributes cannot be used with type-only imports or exports."),
10178
10180
  Import_attribute_values_must_be_string_literal_expressions: diag(2858, 1 /* Error */, "Import_attribute_values_must_be_string_literal_expressions_2858", "Import attribute values must be string literal expressions."),
10179
10181
  Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."),
10182
+ The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method: diag(2860, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2860", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."),
10183
+ An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression: diag(2861, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2861", "An object's '[Symbol.hasInstance]' method must return a boolean value for it to be used on the right-hand side of an 'instanceof' expression."),
10180
10184
  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}'."),
10181
10185
  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}'."),
10182
10186
  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}'."),
@@ -14482,7 +14486,14 @@ function isAccessor(node) {
14482
14486
  function isAutoAccessorPropertyDeclaration(node) {
14483
14487
  return isPropertyDeclaration(node) && hasAccessorModifier(node);
14484
14488
  }
14485
- function isClassFieldAndNotAutoAccessor(node) {
14489
+ function isClassInstanceProperty(node) {
14490
+ if (isInJSFile(node) && isExpandoPropertyDeclaration(node)) {
14491
+ return (!isBindableStaticAccessExpression(node) || !isPrototypeAccess(node.expression)) && !isBindableStaticNameExpression(
14492
+ node,
14493
+ /*excludeThisKeyword*/
14494
+ true
14495
+ );
14496
+ }
14486
14497
  return node.parent && isClassLike(node.parent) && isPropertyDeclaration(node) && !hasAccessorModifier(node);
14487
14498
  }
14488
14499
  function isMethodOrAccessor(node) {
@@ -16915,6 +16926,8 @@ function getInvokedExpression(node) {
16915
16926
  case 286 /* JsxOpeningElement */:
16916
16927
  case 285 /* JsxSelfClosingElement */:
16917
16928
  return node.tagName;
16929
+ case 226 /* BinaryExpression */:
16930
+ return node.right;
16918
16931
  default:
16919
16932
  return node.expression;
16920
16933
  }
@@ -19571,6 +19584,12 @@ function isRightSideOfAccessExpression(node) {
19571
19584
  function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
19572
19585
  return isQualifiedName(node.parent) && node.parent.right === node || isPropertyAccessExpression(node.parent) && node.parent.name === node || isJSDocMemberName(node.parent) && node.parent.right === node;
19573
19586
  }
19587
+ function isInstanceOfExpression(node) {
19588
+ return isBinaryExpression(node) && node.operatorToken.kind === 104 /* InstanceOfKeyword */;
19589
+ }
19590
+ function isRightSideOfInstanceofExpression(node) {
19591
+ return isInstanceOfExpression(node.parent) && node === node.parent.right;
19592
+ }
19574
19593
  function isEmptyObjectLiteral(expression) {
19575
19594
  return expression.kind === 210 /* ObjectLiteralExpression */ && expression.properties.length === 0;
19576
19595
  }
@@ -47779,9 +47798,8 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
47779
47798
  CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
47780
47799
  CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
47781
47800
  CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
47782
- CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
47783
- CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
47784
- CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
47801
+ CheckMode3[CheckMode3["RestBindingElement"] = 32] = "RestBindingElement";
47802
+ CheckMode3[CheckMode3["TypeOnly"] = 64] = "TypeOnly";
47785
47803
  return CheckMode3;
47786
47804
  })(CheckMode || {});
47787
47805
  var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
@@ -48268,7 +48286,7 @@ function createTypeChecker(host) {
48268
48286
  candidates,
48269
48287
  /*argumentCount*/
48270
48288
  void 0,
48271
- 32 /* IsForStringLiteralArgumentCompletions */
48289
+ 0 /* Normal */
48272
48290
  ));
48273
48291
  for (const candidate of candidates) {
48274
48292
  candidatesSet.add(candidate);
@@ -56303,7 +56321,7 @@ function createTypeChecker(host) {
56303
56321
  return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
56304
56322
  }
56305
56323
  function getTypeForBindingElement(declaration) {
56306
- const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
56324
+ const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
56307
56325
  const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
56308
56326
  return parentType && getBindingElementTypeFromParentType(
56309
56327
  declaration,
@@ -68470,7 +68488,7 @@ function createTypeChecker(host) {
68470
68488
  if (!couldContainTypeVariables(target)) {
68471
68489
  return;
68472
68490
  }
68473
- if (source === wildcardType) {
68491
+ if (source === wildcardType || source === blockedStringType) {
68474
68492
  const savePropagationType = propagationType;
68475
68493
  propagationType = source;
68476
68494
  inferFromTypes(target, target);
@@ -68527,6 +68545,10 @@ function createTypeChecker(host) {
68527
68545
  return;
68528
68546
  }
68529
68547
  if (!inference.isFixed) {
68548
+ const candidate = propagationType || source;
68549
+ if (candidate === blockedStringType) {
68550
+ return;
68551
+ }
68530
68552
  if (inference.priority === void 0 || priority < inference.priority) {
68531
68553
  inference.candidates = void 0;
68532
68554
  inference.contraCandidates = void 0;
@@ -68534,7 +68556,6 @@ function createTypeChecker(host) {
68534
68556
  inference.priority = priority;
68535
68557
  }
68536
68558
  if (priority === inference.priority) {
68537
- const candidate = propagationType || source;
68538
68559
  if (contravariant && !bivariant) {
68539
68560
  if (!contains(inference.contraCandidates, candidate)) {
68540
68561
  inference.contraCandidates = append(inference.contraCandidates, candidate);
@@ -69106,7 +69127,7 @@ function createTypeChecker(host) {
69106
69127
  const constraint = getConstraintOfTypeParameter(inference.typeParameter);
69107
69128
  if (constraint) {
69108
69129
  const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
69109
- if (!inferredType || inferredType === blockedStringType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
69130
+ if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
69110
69131
  inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
69111
69132
  }
69112
69133
  }
@@ -69957,7 +69978,10 @@ function createTypeChecker(host) {
69957
69978
  let signature = links.effectsSignature;
69958
69979
  if (signature === void 0) {
69959
69980
  let funcType;
69960
- if (node.parent.kind === 244 /* ExpressionStatement */) {
69981
+ if (isBinaryExpression(node)) {
69982
+ const rightType = checkNonNullExpression(node.right);
69983
+ funcType = getSymbolHasInstanceMethodOfObjectType(rightType);
69984
+ } else if (node.parent.kind === 244 /* ExpressionStatement */) {
69961
69985
  funcType = getTypeOfDottedName(
69962
69986
  node.expression,
69963
69987
  /*diagnostic*/
@@ -70981,7 +71005,22 @@ function createTypeChecker(host) {
70981
71005
  }
70982
71006
  return type;
70983
71007
  }
70984
- const rightType = getTypeOfExpression(expr.right);
71008
+ const right = expr.right;
71009
+ const rightType = getTypeOfExpression(right);
71010
+ if (!isTypeDerivedFrom(rightType, globalObjectType)) {
71011
+ return type;
71012
+ }
71013
+ const signature = getEffectsSignature(expr);
71014
+ const predicate = signature && getTypePredicateOfSignature(signature);
71015
+ if (predicate && predicate.kind === 1 /* Identifier */ && predicate.parameterIndex === 0) {
71016
+ return getNarrowedType(
71017
+ type,
71018
+ predicate.type,
71019
+ assumeTrue,
71020
+ /*checkDerived*/
71021
+ true
71022
+ );
71023
+ }
70985
71024
  if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
70986
71025
  return type;
70987
71026
  }
@@ -71233,7 +71272,7 @@ function createTypeChecker(host) {
71233
71272
  return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
71234
71273
  }
71235
71274
  function hasContextualTypeWithNoGenericTypes(node, checkMode) {
71236
- const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
71275
+ const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 32 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
71237
71276
  node,
71238
71277
  /*contextFlags*/
71239
71278
  void 0
@@ -71993,7 +72032,7 @@ function createTypeChecker(host) {
71993
72032
  function getContextualTypeForBindingElement(declaration, contextFlags) {
71994
72033
  const parent2 = declaration.parent.parent;
71995
72034
  const name = declaration.propertyName || declaration.name;
71996
- const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 208 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
72035
+ const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 208 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
71997
72036
  if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
71998
72037
  return void 0;
71999
72038
  if (parent2.name.kind === 207 /* ArrayBindingPattern */) {
@@ -73976,7 +74015,7 @@ function createTypeChecker(host) {
73976
74015
  }
73977
74016
  return false;
73978
74017
  }
73979
- if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassFieldAndNotAutoAccessor))) {
74018
+ if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassInstanceProperty))) {
73980
74019
  if (errorNode) {
73981
74020
  error2(errorNode, Diagnostics.Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super, symbolToString(prop));
73982
74021
  }
@@ -74839,7 +74878,9 @@ function createTypeChecker(host) {
74839
74878
  checkExpression(node.template);
74840
74879
  } else if (isJsxOpeningLikeElement(node)) {
74841
74880
  checkExpression(node.attributes);
74842
- } else if (node.kind !== 170 /* Decorator */) {
74881
+ } else if (isBinaryExpression(node)) {
74882
+ checkExpression(node.left);
74883
+ } else if (isCallOrNewExpression(node)) {
74843
74884
  forEach(node.arguments, (argument) => {
74844
74885
  checkExpression(argument);
74845
74886
  });
@@ -74912,6 +74953,8 @@ function createTypeChecker(host) {
74912
74953
  }
74913
74954
  } else if (node.kind === 170 /* Decorator */) {
74914
74955
  argCount = getDecoratorArgumentCount(node, signature);
74956
+ } else if (node.kind === 226 /* BinaryExpression */) {
74957
+ argCount = 1;
74915
74958
  } else if (isJsxOpeningLikeElement(node)) {
74916
74959
  callIsIncomplete = node.attributes.end === node.end;
74917
74960
  if (callIsIncomplete) {
@@ -75011,13 +75054,13 @@ function createTypeChecker(host) {
75011
75054
  return voidType;
75012
75055
  }
75013
75056
  const thisArgumentType = checkExpression(thisArgumentNode);
75014
- return isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : thisArgumentType;
75057
+ return isRightSideOfInstanceofExpression(thisArgumentNode) ? thisArgumentType : isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : thisArgumentType;
75015
75058
  }
75016
75059
  function inferTypeArguments(node, signature, args, checkMode, context) {
75017
75060
  if (isJsxOpeningLikeElement(node)) {
75018
75061
  return inferJsxTypeArguments(node, signature, checkMode, context);
75019
75062
  }
75020
- if (node.kind !== 170 /* Decorator */) {
75063
+ if (node.kind !== 170 /* Decorator */ && node.kind !== 226 /* BinaryExpression */) {
75021
75064
  const skipBindingPatterns = every(signature.typeParameters, (p) => !!getDefaultFromTypeParameter(p));
75022
75065
  const contextualType = getContextualType2(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
75023
75066
  if (contextualType) {
@@ -75054,7 +75097,7 @@ function createTypeChecker(host) {
75054
75097
  }
75055
75098
  for (let i = 0; i < argCount; i++) {
75056
75099
  const arg = args[i];
75057
- if (arg.kind !== 232 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
75100
+ if (arg.kind !== 232 /* OmittedExpression */) {
75058
75101
  const paramType = getTypeAtPosition(signature, i);
75059
75102
  if (couldContainTypeVariables(paramType)) {
75060
75103
  const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -75346,6 +75389,9 @@ function createTypeChecker(host) {
75346
75389
  }
75347
75390
  }
75348
75391
  function getThisArgumentOfCall(node) {
75392
+ if (node.kind === 226 /* BinaryExpression */) {
75393
+ return node.right;
75394
+ }
75349
75395
  const expression = node.kind === 213 /* CallExpression */ ? node.expression : node.kind === 215 /* TaggedTemplateExpression */ ? node.tag : node.kind === 170 /* Decorator */ && !legacyDecorators ? node.expression : void 0;
75350
75396
  if (expression) {
75351
75397
  const callee = skipOuterExpressions(expression);
@@ -75374,6 +75420,9 @@ function createTypeChecker(host) {
75374
75420
  if (node.kind === 170 /* Decorator */) {
75375
75421
  return getEffectiveDecoratorArguments(node);
75376
75422
  }
75423
+ if (node.kind === 226 /* BinaryExpression */) {
75424
+ return [node.left];
75425
+ }
75377
75426
  if (isJsxOpeningLikeElement(node)) {
75378
75427
  return node.attributes.properties.length > 0 || isJsxOpeningElement(node) && node.parent.children.length > 0 ? [node.attributes] : emptyArray;
75379
75428
  }
@@ -75643,9 +75692,10 @@ function createTypeChecker(host) {
75643
75692
  const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
75644
75693
  const isDecorator2 = node.kind === 170 /* Decorator */;
75645
75694
  const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
75695
+ const isInstanceof = node.kind === 226 /* BinaryExpression */;
75646
75696
  const reportErrors2 = !isInferencePartiallyBlocked && !candidatesOutArray;
75647
75697
  let typeArguments;
75648
- if (!isDecorator2 && !isSuperCall(node)) {
75698
+ if (!isDecorator2 && !isInstanceof && !isSuperCall(node)) {
75649
75699
  typeArguments = node.typeArguments;
75650
75700
  if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 108 /* SuperKeyword */) {
75651
75701
  forEach(typeArguments, checkSourceElement);
@@ -75657,7 +75707,6 @@ function createTypeChecker(host) {
75657
75707
  const args = getEffectiveCallArguments(node);
75658
75708
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
75659
75709
  let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
75660
- argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
75661
75710
  let candidatesForArgumentError;
75662
75711
  let candidateForArgumentArityError;
75663
75712
  let candidateForTypeArgumentError;
@@ -75675,6 +75724,9 @@ function createTypeChecker(host) {
75675
75724
  result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
75676
75725
  getNodeLinks(node).resolvedSignature = result;
75677
75726
  if (reportErrors2) {
75727
+ if (!headMessage && isInstanceof) {
75728
+ headMessage = Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method;
75729
+ }
75678
75730
  if (candidatesForArgumentError) {
75679
75731
  if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
75680
75732
  const last2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
@@ -76461,6 +76513,30 @@ function createTypeChecker(host) {
76461
76513
  }
76462
76514
  return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
76463
76515
  }
76516
+ function resolveInstanceofExpression(node, candidatesOutArray, checkMode) {
76517
+ const rightType = checkExpression(node.right);
76518
+ if (!isTypeAny(rightType)) {
76519
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
76520
+ if (hasInstanceMethodType) {
76521
+ const apparentType = getApparentType(hasInstanceMethodType);
76522
+ if (isErrorType(apparentType)) {
76523
+ return resolveErrorCall(node);
76524
+ }
76525
+ const callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
76526
+ const constructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */);
76527
+ if (isUntypedFunctionCall(hasInstanceMethodType, apparentType, callSignatures.length, constructSignatures.length)) {
76528
+ return resolveUntypedCall(node);
76529
+ }
76530
+ if (callSignatures.length) {
76531
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
76532
+ }
76533
+ } else if (!(typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
76534
+ error2(node.right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_type_assignable_to_the_Function_interface_type_or_an_object_type_with_a_Symbol_hasInstance_method);
76535
+ return resolveErrorCall(node);
76536
+ }
76537
+ }
76538
+ return anySignature;
76539
+ }
76464
76540
  function isPotentiallyUncalledDecorator(decorator, signatures) {
76465
76541
  return signatures.length && every(signatures, (signature) => signature.minArgumentCount === 0 && !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature));
76466
76542
  }
@@ -76477,6 +76553,8 @@ function createTypeChecker(host) {
76477
76553
  case 286 /* JsxOpeningElement */:
76478
76554
  case 285 /* JsxSelfClosingElement */:
76479
76555
  return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
76556
+ case 226 /* BinaryExpression */:
76557
+ return resolveInstanceofExpression(node, candidatesOutArray, checkMode);
76480
76558
  }
76481
76559
  Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
76482
76560
  }
@@ -78435,16 +78513,35 @@ function createTypeChecker(host) {
78435
78513
  function isConstEnumSymbol(symbol) {
78436
78514
  return (symbol.flags & 128 /* ConstEnum */) !== 0;
78437
78515
  }
78438
- function checkInstanceOfExpression(left, right, leftType, rightType) {
78516
+ function getSymbolHasInstanceMethodOfObjectType(type) {
78517
+ const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
78518
+ const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
78519
+ if (hasInstanceProperty) {
78520
+ const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
78521
+ if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
78522
+ return hasInstancePropertyType;
78523
+ }
78524
+ }
78525
+ }
78526
+ function checkInstanceOfExpression(left, right, leftType, rightType, checkMode) {
78439
78527
  if (leftType === silentNeverType || rightType === silentNeverType) {
78440
78528
  return silentNeverType;
78441
78529
  }
78442
78530
  if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
78443
78531
  error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
78444
78532
  }
78445
- if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
78446
- 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);
78533
+ Debug.assert(isInstanceOfExpression(left.parent));
78534
+ const signature = getResolvedSignature(
78535
+ left.parent,
78536
+ /*candidatesOutArray*/
78537
+ void 0,
78538
+ checkMode
78539
+ );
78540
+ if (signature === resolvingSignature) {
78541
+ return silentNeverType;
78447
78542
  }
78543
+ const returnType = getReturnTypeOfSignature(signature);
78544
+ 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);
78448
78545
  return booleanType;
78449
78546
  }
78450
78547
  function hasEmptyObjectIntersection(type) {
@@ -78982,7 +79079,7 @@ function createTypeChecker(host) {
78982
79079
  case 36 /* ExclamationEqualsToken */:
78983
79080
  case 37 /* EqualsEqualsEqualsToken */:
78984
79081
  case 38 /* ExclamationEqualsEqualsToken */:
78985
- if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
79082
+ if (!(checkMode && checkMode & 64 /* TypeOnly */)) {
78986
79083
  if ((isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) && // only report for === and !== in JS, not == or !=
78987
79084
  (!isInJSFile(left) || (operator === 37 /* EqualsEqualsEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */))) {
78988
79085
  const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
@@ -78993,7 +79090,7 @@ function createTypeChecker(host) {
78993
79090
  }
78994
79091
  return booleanType;
78995
79092
  case 104 /* InstanceOfKeyword */:
78996
- return checkInstanceOfExpression(left, right, leftType, rightType);
79093
+ return checkInstanceOfExpression(left, right, leftType, rightType, checkMode);
78997
79094
  case 103 /* InKeyword */:
78998
79095
  return checkInExpression(left, right, leftType, rightType);
78999
79096
  case 56 /* AmpersandAmpersandToken */:
@@ -79630,7 +79727,7 @@ function createTypeChecker(host) {
79630
79727
  }
79631
79728
  }
79632
79729
  const startInvocationCount = flowInvocationCount;
79633
- const type = checkExpression(node, 128 /* TypeOnly */);
79730
+ const type = checkExpression(node, 64 /* TypeOnly */);
79634
79731
  if (flowInvocationCount !== startInvocationCount) {
79635
79732
  const cache = flowTypeCache || (flowTypeCache = []);
79636
79733
  cache[getNodeId(node)] = type;
@@ -82096,7 +82193,7 @@ function createTypeChecker(host) {
82096
82193
  checkComputedPropertyName(node.propertyName);
82097
82194
  }
82098
82195
  const parent2 = node.parent.parent;
82099
- const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
82196
+ const parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
82100
82197
  const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
82101
82198
  const name = node.propertyName || node.name;
82102
82199
  if (parentType && !isBindingPattern(name)) {
@@ -84313,7 +84410,7 @@ function createTypeChecker(host) {
84313
84410
  }
84314
84411
  if (isConstantVariable(symbol)) {
84315
84412
  const declaration = symbol.valueDeclaration;
84316
- if (declaration && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
84413
+ if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
84317
84414
  return evaluate(declaration.initializer, declaration);
84318
84415
  }
84319
84416
  }
@@ -85405,6 +85502,12 @@ function createTypeChecker(host) {
85405
85502
  case 234 /* AsExpression */:
85406
85503
  case 217 /* ParenthesizedExpression */:
85407
85504
  checkAssertionDeferred(node);
85505
+ break;
85506
+ case 226 /* BinaryExpression */:
85507
+ if (isInstanceOfExpression(node)) {
85508
+ resolveUntypedCall(node);
85509
+ }
85510
+ break;
85408
85511
  }
85409
85512
  currentNode = saveCurrentNode;
85410
85513
  (_b = tracing) == null ? void 0 : _b.pop();
@@ -86021,6 +86124,13 @@ function createTypeChecker(host) {
86021
86124
  case 102 /* ImportKeyword */:
86022
86125
  case 105 /* NewKeyword */:
86023
86126
  return isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : void 0;
86127
+ case 104 /* InstanceOfKeyword */:
86128
+ if (isBinaryExpression(node.parent)) {
86129
+ const type = getTypeOfExpression(node.parent.right);
86130
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(type);
86131
+ return (hasInstanceMethodType == null ? void 0 : hasInstanceMethodType.symbol) ?? type.symbol;
86132
+ }
86133
+ return void 0;
86024
86134
  case 236 /* MetaProperty */:
86025
86135
  return checkExpression(node).symbol;
86026
86136
  case 295 /* JsxNamespacedName */:
@@ -164277,14 +164387,14 @@ function provideInlayHints(context) {
164277
164387
  if (isModuleReferenceType(declarationType)) {
164278
164388
  return;
164279
164389
  }
164280
- const hints = typeToInlayHintParts(declarationType);
164281
- if (hints) {
164282
- const hintText = typeof hints === "string" ? hints : hints.map((part) => part.text).join("");
164390
+ const hintParts = typeToInlayHintParts(declarationType);
164391
+ if (hintParts) {
164392
+ const hintText = typeof hintParts === "string" ? hintParts : hintParts.map((part) => part.text).join("");
164283
164393
  const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), hintText);
164284
164394
  if (isVariableNameMatchesType) {
164285
164395
  return;
164286
164396
  }
164287
- addTypeHints(hints, decl.name.end);
164397
+ addTypeHints(hintParts, decl.name.end);
164288
164398
  }
164289
164399
  }
164290
164400
  function visitCallOrNewExpression(expr) {
@@ -164392,9 +164502,9 @@ function provideInlayHints(context) {
164392
164502
  if (isModuleReferenceType(returnType)) {
164393
164503
  return;
164394
164504
  }
164395
- const hint = typeToInlayHintParts(returnType);
164396
- if (hint) {
164397
- addTypeHints(hint, getTypeAnnotationPosition(decl));
164505
+ const hintParts = typeToInlayHintParts(returnType);
164506
+ if (hintParts) {
164507
+ addTypeHints(hintParts, getTypeAnnotationPosition(decl));
164398
164508
  }
164399
164509
  }
164400
164510
  function getTypeAnnotationPosition(decl) {
@@ -164418,14 +164528,14 @@ function provideInlayHints(context) {
164418
164528
  if (effectiveTypeAnnotation) {
164419
164529
  continue;
164420
164530
  }
164421
- const typeDisplayString = getParameterDeclarationTypeDisplayString(signature.parameters[i]);
164422
- if (!typeDisplayString) {
164531
+ const typeHints = getParameterDeclarationTypeHints(signature.parameters[i]);
164532
+ if (!typeHints) {
164423
164533
  continue;
164424
164534
  }
164425
- addTypeHints(typeDisplayString, param.questionToken ? param.questionToken.end : param.name.end);
164535
+ addTypeHints(typeHints, param.questionToken ? param.questionToken.end : param.name.end);
164426
164536
  }
164427
164537
  }
164428
- function getParameterDeclarationTypeDisplayString(symbol) {
164538
+ function getParameterDeclarationTypeHints(symbol) {
164429
164539
  const valueDeclaration = symbol.valueDeclaration;
164430
164540
  if (!valueDeclaration || !isParameter(valueDeclaration)) {
164431
164541
  return void 0;
@@ -164434,7 +164544,7 @@ function provideInlayHints(context) {
164434
164544
  if (isModuleReferenceType(signatureParamType)) {
164435
164545
  return void 0;
164436
164546
  }
164437
- return printTypeInSingleLine(signatureParamType);
164547
+ return typeToInlayHintParts(signatureParamType);
164438
164548
  }
164439
164549
  function printTypeInSingleLine(type) {
164440
164550
  const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
@@ -173018,7 +173128,7 @@ __export(ts_exports2, {
173018
173128
  isClassDeclaration: () => isClassDeclaration,
173019
173129
  isClassElement: () => isClassElement,
173020
173130
  isClassExpression: () => isClassExpression,
173021
- isClassFieldAndNotAutoAccessor: () => isClassFieldAndNotAutoAccessor,
173131
+ isClassInstanceProperty: () => isClassInstanceProperty,
173022
173132
  isClassLike: () => isClassLike,
173023
173133
  isClassMemberModifier: () => isClassMemberModifier,
173024
173134
  isClassNamedEvaluationHelperBlock: () => isClassNamedEvaluationHelperBlock,
@@ -173209,6 +173319,7 @@ __export(ts_exports2, {
173209
173319
  isInsideJsxElementOrAttribute: () => isInsideJsxElementOrAttribute,
173210
173320
  isInsideNodeModules: () => isInsideNodeModules,
173211
173321
  isInsideTemplateLiteral: () => isInsideTemplateLiteral,
173322
+ isInstanceOfExpression: () => isInstanceOfExpression,
173212
173323
  isInstantiatedModule: () => isInstantiatedModule,
173213
173324
  isInterfaceDeclaration: () => isInterfaceDeclaration,
173214
173325
  isInternalDeclaration: () => isInternalDeclaration,
@@ -173466,6 +173577,7 @@ __export(ts_exports2, {
173466
173577
  isReturnStatement: () => isReturnStatement,
173467
173578
  isReturnStatementWithFixablePromiseHandler: () => isReturnStatementWithFixablePromiseHandler,
173468
173579
  isRightSideOfAccessExpression: () => isRightSideOfAccessExpression,
173580
+ isRightSideOfInstanceofExpression: () => isRightSideOfInstanceofExpression,
173469
173581
  isRightSideOfPropertyAccess: () => isRightSideOfPropertyAccess,
173470
173582
  isRightSideOfQualifiedName: () => isRightSideOfQualifiedName,
173471
173583
  isRightSideOfQualifiedNameOrPropertyAccess: () => isRightSideOfQualifiedNameOrPropertyAccess,
@@ -187695,7 +187807,7 @@ start(initializeNodeSystem(), require("os").platform());
187695
187807
  isClassDeclaration,
187696
187808
  isClassElement,
187697
187809
  isClassExpression,
187698
- isClassFieldAndNotAutoAccessor,
187810
+ isClassInstanceProperty,
187699
187811
  isClassLike,
187700
187812
  isClassMemberModifier,
187701
187813
  isClassNamedEvaluationHelperBlock,
@@ -187886,6 +187998,7 @@ start(initializeNodeSystem(), require("os").platform());
187886
187998
  isInsideJsxElementOrAttribute,
187887
187999
  isInsideNodeModules,
187888
188000
  isInsideTemplateLiteral,
188001
+ isInstanceOfExpression,
187889
188002
  isInstantiatedModule,
187890
188003
  isInterfaceDeclaration,
187891
188004
  isInternalDeclaration,
@@ -188143,6 +188256,7 @@ start(initializeNodeSystem(), require("os").platform());
188143
188256
  isReturnStatement,
188144
188257
  isReturnStatementWithFixablePromiseHandler,
188145
188258
  isRightSideOfAccessExpression,
188259
+ isRightSideOfInstanceofExpression,
188146
188260
  isRightSideOfPropertyAccess,
188147
188261
  isRightSideOfQualifiedName,
188148
188262
  isRightSideOfQualifiedNameOrPropertyAccess,
@@ -5646,7 +5646,10 @@ declare namespace ts {
5646
5646
  readonly typeArguments?: NodeArray<TypeNode>;
5647
5647
  readonly template: TemplateLiteral;
5648
5648
  }
5649
- type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement;
5649
+ interface InstanceofExpression extends BinaryExpression {
5650
+ readonly operatorToken: Token<SyntaxKind.InstanceOfKeyword>;
5651
+ }
5652
+ type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement | InstanceofExpression;
5650
5653
  interface AsExpression extends Expression {
5651
5654
  readonly kind: SyntaxKind.AsExpression;
5652
5655
  readonly expression: Expression;