typescript 5.3.0-dev.20230928 → 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/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.3";
38
- version = `${versionMajorMinor}.0-dev.20230928`;
38
+ version = `${versionMajorMinor}.0-dev.20230930`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -5186,12 +5186,12 @@ ${lanes.join("\n")}
5186
5186
  kind: 4 /* MultiLine */
5187
5187
  }
5188
5188
  };
5189
- JSDocParsingMode = /* @__PURE__ */ ((JSDocParsingMode7) => {
5190
- JSDocParsingMode7[JSDocParsingMode7["ParseAll"] = 0] = "ParseAll";
5191
- JSDocParsingMode7[JSDocParsingMode7["ParseNone"] = 1] = "ParseNone";
5192
- JSDocParsingMode7[JSDocParsingMode7["ParseForTypeErrors"] = 2] = "ParseForTypeErrors";
5193
- JSDocParsingMode7[JSDocParsingMode7["ParseForTypeInfo"] = 3] = "ParseForTypeInfo";
5194
- return JSDocParsingMode7;
5189
+ JSDocParsingMode = /* @__PURE__ */ ((JSDocParsingMode6) => {
5190
+ JSDocParsingMode6[JSDocParsingMode6["ParseAll"] = 0] = "ParseAll";
5191
+ JSDocParsingMode6[JSDocParsingMode6["ParseNone"] = 1] = "ParseNone";
5192
+ JSDocParsingMode6[JSDocParsingMode6["ParseForTypeErrors"] = 2] = "ParseForTypeErrors";
5193
+ JSDocParsingMode6[JSDocParsingMode6["ParseForTypeInfo"] = 3] = "ParseForTypeInfo";
5194
+ return JSDocParsingMode6;
5195
5195
  })(JSDocParsingMode || {});
5196
5196
  }
5197
5197
  });
@@ -7512,7 +7512,7 @@ ${lanes.join("\n")}
7512
7512
  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."),
7513
7513
  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."),
7514
7514
  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."),
7515
- 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."),
7515
+ 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."),
7516
7516
  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."),
7517
7517
  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."),
7518
7518
  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."),
@@ -7961,6 +7961,8 @@ ${lanes.join("\n")}
7961
7961
  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."),
7962
7962
  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."),
7963
7963
  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}'."),
7964
+ 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."),
7965
+ 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."),
7964
7966
  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}'."),
7965
7967
  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}'."),
7966
7968
  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}'."),
@@ -12273,7 +12275,14 @@ ${lanes.join("\n")}
12273
12275
  function isAutoAccessorPropertyDeclaration(node) {
12274
12276
  return isPropertyDeclaration(node) && hasAccessorModifier(node);
12275
12277
  }
12276
- function isClassFieldAndNotAutoAccessor(node) {
12278
+ function isClassInstanceProperty(node) {
12279
+ if (isInJSFile(node) && isExpandoPropertyDeclaration(node)) {
12280
+ return (!isBindableStaticAccessExpression(node) || !isPrototypeAccess(node.expression)) && !isBindableStaticNameExpression(
12281
+ node,
12282
+ /*excludeThisKeyword*/
12283
+ true
12284
+ );
12285
+ }
12277
12286
  return node.parent && isClassLike(node.parent) && isPropertyDeclaration(node) && !hasAccessorModifier(node);
12278
12287
  }
12279
12288
  function isMethodOrAccessor(node) {
@@ -14300,6 +14309,8 @@ ${lanes.join("\n")}
14300
14309
  case 286 /* JsxOpeningElement */:
14301
14310
  case 285 /* JsxSelfClosingElement */:
14302
14311
  return node.tagName;
14312
+ case 226 /* BinaryExpression */:
14313
+ return node.right;
14303
14314
  default:
14304
14315
  return node.expression;
14305
14316
  }
@@ -16877,6 +16888,12 @@ ${lanes.join("\n")}
16877
16888
  function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
16878
16889
  return isQualifiedName(node.parent) && node.parent.right === node || isPropertyAccessExpression(node.parent) && node.parent.name === node || isJSDocMemberName(node.parent) && node.parent.right === node;
16879
16890
  }
16891
+ function isInstanceOfExpression(node) {
16892
+ return isBinaryExpression(node) && node.operatorToken.kind === 104 /* InstanceOfKeyword */;
16893
+ }
16894
+ function isRightSideOfInstanceofExpression(node) {
16895
+ return isInstanceOfExpression(node.parent) && node === node.parent.right;
16896
+ }
16880
16897
  function isEmptyObjectLiteral(expression) {
16881
16898
  return expression.kind === 210 /* ObjectLiteralExpression */ && expression.properties.length === 0;
16882
16899
  }
@@ -46036,7 +46053,7 @@ ${lanes.join("\n")}
46036
46053
  candidates,
46037
46054
  /*argumentCount*/
46038
46055
  void 0,
46039
- 32 /* IsForStringLiteralArgumentCompletions */
46056
+ 0 /* Normal */
46040
46057
  ));
46041
46058
  for (const candidate of candidates) {
46042
46059
  candidatesSet.add(candidate);
@@ -54071,7 +54088,7 @@ ${lanes.join("\n")}
54071
54088
  return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
54072
54089
  }
54073
54090
  function getTypeForBindingElement(declaration) {
54074
- const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
54091
+ const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
54075
54092
  const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
54076
54093
  return parentType && getBindingElementTypeFromParentType(
54077
54094
  declaration,
@@ -66238,7 +66255,7 @@ ${lanes.join("\n")}
66238
66255
  if (!couldContainTypeVariables(target)) {
66239
66256
  return;
66240
66257
  }
66241
- if (source === wildcardType) {
66258
+ if (source === wildcardType || source === blockedStringType) {
66242
66259
  const savePropagationType = propagationType;
66243
66260
  propagationType = source;
66244
66261
  inferFromTypes(target, target);
@@ -66295,6 +66312,10 @@ ${lanes.join("\n")}
66295
66312
  return;
66296
66313
  }
66297
66314
  if (!inference.isFixed) {
66315
+ const candidate = propagationType || source;
66316
+ if (candidate === blockedStringType) {
66317
+ return;
66318
+ }
66298
66319
  if (inference.priority === void 0 || priority < inference.priority) {
66299
66320
  inference.candidates = void 0;
66300
66321
  inference.contraCandidates = void 0;
@@ -66302,7 +66323,6 @@ ${lanes.join("\n")}
66302
66323
  inference.priority = priority;
66303
66324
  }
66304
66325
  if (priority === inference.priority) {
66305
- const candidate = propagationType || source;
66306
66326
  if (contravariant && !bivariant) {
66307
66327
  if (!contains(inference.contraCandidates, candidate)) {
66308
66328
  inference.contraCandidates = append(inference.contraCandidates, candidate);
@@ -66874,7 +66894,7 @@ ${lanes.join("\n")}
66874
66894
  const constraint = getConstraintOfTypeParameter(inference.typeParameter);
66875
66895
  if (constraint) {
66876
66896
  const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
66877
- if (!inferredType || inferredType === blockedStringType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
66897
+ if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
66878
66898
  inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
66879
66899
  }
66880
66900
  }
@@ -67725,7 +67745,10 @@ ${lanes.join("\n")}
67725
67745
  let signature = links.effectsSignature;
67726
67746
  if (signature === void 0) {
67727
67747
  let funcType;
67728
- if (node.parent.kind === 244 /* ExpressionStatement */) {
67748
+ if (isBinaryExpression(node)) {
67749
+ const rightType = checkNonNullExpression(node.right);
67750
+ funcType = getSymbolHasInstanceMethodOfObjectType(rightType);
67751
+ } else if (node.parent.kind === 244 /* ExpressionStatement */) {
67729
67752
  funcType = getTypeOfDottedName(
67730
67753
  node.expression,
67731
67754
  /*diagnostic*/
@@ -68749,7 +68772,22 @@ ${lanes.join("\n")}
68749
68772
  }
68750
68773
  return type;
68751
68774
  }
68752
- const rightType = getTypeOfExpression(expr.right);
68775
+ const right = expr.right;
68776
+ const rightType = getTypeOfExpression(right);
68777
+ if (!isTypeDerivedFrom(rightType, globalObjectType)) {
68778
+ return type;
68779
+ }
68780
+ const signature = getEffectsSignature(expr);
68781
+ const predicate = signature && getTypePredicateOfSignature(signature);
68782
+ if (predicate && predicate.kind === 1 /* Identifier */ && predicate.parameterIndex === 0) {
68783
+ return getNarrowedType(
68784
+ type,
68785
+ predicate.type,
68786
+ assumeTrue,
68787
+ /*checkDerived*/
68788
+ true
68789
+ );
68790
+ }
68753
68791
  if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
68754
68792
  return type;
68755
68793
  }
@@ -69001,7 +69039,7 @@ ${lanes.join("\n")}
69001
69039
  return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
69002
69040
  }
69003
69041
  function hasContextualTypeWithNoGenericTypes(node, checkMode) {
69004
- 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(
69042
+ 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(
69005
69043
  node,
69006
69044
  /*contextFlags*/
69007
69045
  void 0
@@ -69761,7 +69799,7 @@ ${lanes.join("\n")}
69761
69799
  function getContextualTypeForBindingElement(declaration, contextFlags) {
69762
69800
  const parent2 = declaration.parent.parent;
69763
69801
  const name = declaration.propertyName || declaration.name;
69764
- const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 208 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
69802
+ const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 208 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
69765
69803
  if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
69766
69804
  return void 0;
69767
69805
  if (parent2.name.kind === 207 /* ArrayBindingPattern */) {
@@ -71744,7 +71782,7 @@ ${lanes.join("\n")}
71744
71782
  }
71745
71783
  return false;
71746
71784
  }
71747
- if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassFieldAndNotAutoAccessor))) {
71785
+ if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassInstanceProperty))) {
71748
71786
  if (errorNode) {
71749
71787
  error2(errorNode, Diagnostics.Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super, symbolToString(prop));
71750
71788
  }
@@ -72607,7 +72645,9 @@ ${lanes.join("\n")}
72607
72645
  checkExpression(node.template);
72608
72646
  } else if (isJsxOpeningLikeElement(node)) {
72609
72647
  checkExpression(node.attributes);
72610
- } else if (node.kind !== 170 /* Decorator */) {
72648
+ } else if (isBinaryExpression(node)) {
72649
+ checkExpression(node.left);
72650
+ } else if (isCallOrNewExpression(node)) {
72611
72651
  forEach(node.arguments, (argument) => {
72612
72652
  checkExpression(argument);
72613
72653
  });
@@ -72680,6 +72720,8 @@ ${lanes.join("\n")}
72680
72720
  }
72681
72721
  } else if (node.kind === 170 /* Decorator */) {
72682
72722
  argCount = getDecoratorArgumentCount(node, signature);
72723
+ } else if (node.kind === 226 /* BinaryExpression */) {
72724
+ argCount = 1;
72683
72725
  } else if (isJsxOpeningLikeElement(node)) {
72684
72726
  callIsIncomplete = node.attributes.end === node.end;
72685
72727
  if (callIsIncomplete) {
@@ -72779,13 +72821,13 @@ ${lanes.join("\n")}
72779
72821
  return voidType;
72780
72822
  }
72781
72823
  const thisArgumentType = checkExpression(thisArgumentNode);
72782
- return isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : thisArgumentType;
72824
+ return isRightSideOfInstanceofExpression(thisArgumentNode) ? thisArgumentType : isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : thisArgumentType;
72783
72825
  }
72784
72826
  function inferTypeArguments(node, signature, args, checkMode, context) {
72785
72827
  if (isJsxOpeningLikeElement(node)) {
72786
72828
  return inferJsxTypeArguments(node, signature, checkMode, context);
72787
72829
  }
72788
- if (node.kind !== 170 /* Decorator */) {
72830
+ if (node.kind !== 170 /* Decorator */ && node.kind !== 226 /* BinaryExpression */) {
72789
72831
  const skipBindingPatterns = every(signature.typeParameters, (p) => !!getDefaultFromTypeParameter(p));
72790
72832
  const contextualType = getContextualType2(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
72791
72833
  if (contextualType) {
@@ -72822,7 +72864,7 @@ ${lanes.join("\n")}
72822
72864
  }
72823
72865
  for (let i = 0; i < argCount; i++) {
72824
72866
  const arg = args[i];
72825
- if (arg.kind !== 232 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
72867
+ if (arg.kind !== 232 /* OmittedExpression */) {
72826
72868
  const paramType = getTypeAtPosition(signature, i);
72827
72869
  if (couldContainTypeVariables(paramType)) {
72828
72870
  const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -73114,6 +73156,9 @@ ${lanes.join("\n")}
73114
73156
  }
73115
73157
  }
73116
73158
  function getThisArgumentOfCall(node) {
73159
+ if (node.kind === 226 /* BinaryExpression */) {
73160
+ return node.right;
73161
+ }
73117
73162
  const expression = node.kind === 213 /* CallExpression */ ? node.expression : node.kind === 215 /* TaggedTemplateExpression */ ? node.tag : node.kind === 170 /* Decorator */ && !legacyDecorators ? node.expression : void 0;
73118
73163
  if (expression) {
73119
73164
  const callee = skipOuterExpressions(expression);
@@ -73142,6 +73187,9 @@ ${lanes.join("\n")}
73142
73187
  if (node.kind === 170 /* Decorator */) {
73143
73188
  return getEffectiveDecoratorArguments(node);
73144
73189
  }
73190
+ if (node.kind === 226 /* BinaryExpression */) {
73191
+ return [node.left];
73192
+ }
73145
73193
  if (isJsxOpeningLikeElement(node)) {
73146
73194
  return node.attributes.properties.length > 0 || isJsxOpeningElement(node) && node.parent.children.length > 0 ? [node.attributes] : emptyArray;
73147
73195
  }
@@ -73411,9 +73459,10 @@ ${lanes.join("\n")}
73411
73459
  const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
73412
73460
  const isDecorator2 = node.kind === 170 /* Decorator */;
73413
73461
  const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
73462
+ const isInstanceof = node.kind === 226 /* BinaryExpression */;
73414
73463
  const reportErrors2 = !isInferencePartiallyBlocked && !candidatesOutArray;
73415
73464
  let typeArguments;
73416
- if (!isDecorator2 && !isSuperCall(node)) {
73465
+ if (!isDecorator2 && !isInstanceof && !isSuperCall(node)) {
73417
73466
  typeArguments = node.typeArguments;
73418
73467
  if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 108 /* SuperKeyword */) {
73419
73468
  forEach(typeArguments, checkSourceElement);
@@ -73425,7 +73474,6 @@ ${lanes.join("\n")}
73425
73474
  const args = getEffectiveCallArguments(node);
73426
73475
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
73427
73476
  let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
73428
- argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
73429
73477
  let candidatesForArgumentError;
73430
73478
  let candidateForArgumentArityError;
73431
73479
  let candidateForTypeArgumentError;
@@ -73443,6 +73491,9 @@ ${lanes.join("\n")}
73443
73491
  result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
73444
73492
  getNodeLinks(node).resolvedSignature = result;
73445
73493
  if (reportErrors2) {
73494
+ if (!headMessage && isInstanceof) {
73495
+ 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;
73496
+ }
73446
73497
  if (candidatesForArgumentError) {
73447
73498
  if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
73448
73499
  const last2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
@@ -74229,6 +74280,30 @@ ${lanes.join("\n")}
74229
74280
  }
74230
74281
  return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
74231
74282
  }
74283
+ function resolveInstanceofExpression(node, candidatesOutArray, checkMode) {
74284
+ const rightType = checkExpression(node.right);
74285
+ if (!isTypeAny(rightType)) {
74286
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
74287
+ if (hasInstanceMethodType) {
74288
+ const apparentType = getApparentType(hasInstanceMethodType);
74289
+ if (isErrorType(apparentType)) {
74290
+ return resolveErrorCall(node);
74291
+ }
74292
+ const callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
74293
+ const constructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */);
74294
+ if (isUntypedFunctionCall(hasInstanceMethodType, apparentType, callSignatures.length, constructSignatures.length)) {
74295
+ return resolveUntypedCall(node);
74296
+ }
74297
+ if (callSignatures.length) {
74298
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
74299
+ }
74300
+ } else if (!(typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
74301
+ 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);
74302
+ return resolveErrorCall(node);
74303
+ }
74304
+ }
74305
+ return anySignature;
74306
+ }
74232
74307
  function isPotentiallyUncalledDecorator(decorator, signatures) {
74233
74308
  return signatures.length && every(signatures, (signature) => signature.minArgumentCount === 0 && !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature));
74234
74309
  }
@@ -74245,6 +74320,8 @@ ${lanes.join("\n")}
74245
74320
  case 286 /* JsxOpeningElement */:
74246
74321
  case 285 /* JsxSelfClosingElement */:
74247
74322
  return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
74323
+ case 226 /* BinaryExpression */:
74324
+ return resolveInstanceofExpression(node, candidatesOutArray, checkMode);
74248
74325
  }
74249
74326
  Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
74250
74327
  }
@@ -76203,16 +76280,35 @@ ${lanes.join("\n")}
76203
76280
  function isConstEnumSymbol(symbol) {
76204
76281
  return (symbol.flags & 128 /* ConstEnum */) !== 0;
76205
76282
  }
76206
- function checkInstanceOfExpression(left, right, leftType, rightType) {
76283
+ function getSymbolHasInstanceMethodOfObjectType(type) {
76284
+ const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
76285
+ const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
76286
+ if (hasInstanceProperty) {
76287
+ const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
76288
+ if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
76289
+ return hasInstancePropertyType;
76290
+ }
76291
+ }
76292
+ }
76293
+ function checkInstanceOfExpression(left, right, leftType, rightType, checkMode) {
76207
76294
  if (leftType === silentNeverType || rightType === silentNeverType) {
76208
76295
  return silentNeverType;
76209
76296
  }
76210
76297
  if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
76211
76298
  error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
76212
76299
  }
76213
- if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
76214
- 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);
76300
+ Debug.assert(isInstanceOfExpression(left.parent));
76301
+ const signature = getResolvedSignature(
76302
+ left.parent,
76303
+ /*candidatesOutArray*/
76304
+ void 0,
76305
+ checkMode
76306
+ );
76307
+ if (signature === resolvingSignature) {
76308
+ return silentNeverType;
76215
76309
  }
76310
+ const returnType = getReturnTypeOfSignature(signature);
76311
+ 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);
76216
76312
  return booleanType;
76217
76313
  }
76218
76314
  function hasEmptyObjectIntersection(type) {
@@ -76750,7 +76846,7 @@ ${lanes.join("\n")}
76750
76846
  case 36 /* ExclamationEqualsToken */:
76751
76847
  case 37 /* EqualsEqualsEqualsToken */:
76752
76848
  case 38 /* ExclamationEqualsEqualsToken */:
76753
- if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
76849
+ if (!(checkMode && checkMode & 64 /* TypeOnly */)) {
76754
76850
  if ((isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) && // only report for === and !== in JS, not == or !=
76755
76851
  (!isInJSFile(left) || (operator === 37 /* EqualsEqualsEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */))) {
76756
76852
  const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
@@ -76761,7 +76857,7 @@ ${lanes.join("\n")}
76761
76857
  }
76762
76858
  return booleanType;
76763
76859
  case 104 /* InstanceOfKeyword */:
76764
- return checkInstanceOfExpression(left, right, leftType, rightType);
76860
+ return checkInstanceOfExpression(left, right, leftType, rightType, checkMode);
76765
76861
  case 103 /* InKeyword */:
76766
76862
  return checkInExpression(left, right, leftType, rightType);
76767
76863
  case 56 /* AmpersandAmpersandToken */:
@@ -77398,7 +77494,7 @@ ${lanes.join("\n")}
77398
77494
  }
77399
77495
  }
77400
77496
  const startInvocationCount = flowInvocationCount;
77401
- const type = checkExpression(node, 128 /* TypeOnly */);
77497
+ const type = checkExpression(node, 64 /* TypeOnly */);
77402
77498
  if (flowInvocationCount !== startInvocationCount) {
77403
77499
  const cache = flowTypeCache || (flowTypeCache = []);
77404
77500
  cache[getNodeId(node)] = type;
@@ -79864,7 +79960,7 @@ ${lanes.join("\n")}
79864
79960
  checkComputedPropertyName(node.propertyName);
79865
79961
  }
79866
79962
  const parent2 = node.parent.parent;
79867
- const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
79963
+ const parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
79868
79964
  const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
79869
79965
  const name = node.propertyName || node.name;
79870
79966
  if (parentType && !isBindingPattern(name)) {
@@ -82081,7 +82177,7 @@ ${lanes.join("\n")}
82081
82177
  }
82082
82178
  if (isConstantVariable(symbol)) {
82083
82179
  const declaration = symbol.valueDeclaration;
82084
- if (declaration && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
82180
+ if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
82085
82181
  return evaluate(declaration.initializer, declaration);
82086
82182
  }
82087
82183
  }
@@ -83173,6 +83269,12 @@ ${lanes.join("\n")}
83173
83269
  case 234 /* AsExpression */:
83174
83270
  case 217 /* ParenthesizedExpression */:
83175
83271
  checkAssertionDeferred(node);
83272
+ break;
83273
+ case 226 /* BinaryExpression */:
83274
+ if (isInstanceOfExpression(node)) {
83275
+ resolveUntypedCall(node);
83276
+ }
83277
+ break;
83176
83278
  }
83177
83279
  currentNode = saveCurrentNode;
83178
83280
  (_b = tracing) == null ? void 0 : _b.pop();
@@ -83789,6 +83891,13 @@ ${lanes.join("\n")}
83789
83891
  case 102 /* ImportKeyword */:
83790
83892
  case 105 /* NewKeyword */:
83791
83893
  return isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : void 0;
83894
+ case 104 /* InstanceOfKeyword */:
83895
+ if (isBinaryExpression(node.parent)) {
83896
+ const type = getTypeOfExpression(node.parent.right);
83897
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(type);
83898
+ return (hasInstanceMethodType == null ? void 0 : hasInstanceMethodType.symbol) ?? type.symbol;
83899
+ }
83900
+ return void 0;
83792
83901
  case 236 /* MetaProperty */:
83793
83902
  return checkExpression(node).symbol;
83794
83903
  case 295 /* JsxNamespacedName */:
@@ -86686,9 +86795,8 @@ ${lanes.join("\n")}
86686
86795
  CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
86687
86796
  CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
86688
86797
  CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
86689
- CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
86690
- CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
86691
- CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
86798
+ CheckMode3[CheckMode3["RestBindingElement"] = 32] = "RestBindingElement";
86799
+ CheckMode3[CheckMode3["TypeOnly"] = 64] = "TypeOnly";
86692
86800
  return CheckMode3;
86693
86801
  })(CheckMode || {});
86694
86802
  SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
@@ -128824,10 +128932,10 @@ ${lanes.join("\n")}
128824
128932
  return LanguageServiceMode2;
128825
128933
  })(LanguageServiceMode || {});
128826
128934
  emptyOptions = {};
128827
- SemanticClassificationFormat = /* @__PURE__ */ ((SemanticClassificationFormat3) => {
128828
- SemanticClassificationFormat3["Original"] = "original";
128829
- SemanticClassificationFormat3["TwentyTwenty"] = "2020";
128830
- return SemanticClassificationFormat3;
128935
+ SemanticClassificationFormat = /* @__PURE__ */ ((SemanticClassificationFormat2) => {
128936
+ SemanticClassificationFormat2["Original"] = "original";
128937
+ SemanticClassificationFormat2["TwentyTwenty"] = "2020";
128938
+ return SemanticClassificationFormat2;
128831
128939
  })(SemanticClassificationFormat || {});
128832
128940
  OrganizeImportsMode = /* @__PURE__ */ ((OrganizeImportsMode3) => {
128833
128941
  OrganizeImportsMode3["All"] = "All";
@@ -128918,15 +129026,15 @@ ${lanes.join("\n")}
128918
129026
  OutputFileType2[OutputFileType2["Declaration"] = 2] = "Declaration";
128919
129027
  return OutputFileType2;
128920
129028
  })(OutputFileType || {});
128921
- EndOfLineState = /* @__PURE__ */ ((EndOfLineState3) => {
128922
- EndOfLineState3[EndOfLineState3["None"] = 0] = "None";
128923
- EndOfLineState3[EndOfLineState3["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia";
128924
- EndOfLineState3[EndOfLineState3["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral";
128925
- EndOfLineState3[EndOfLineState3["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral";
128926
- EndOfLineState3[EndOfLineState3["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate";
128927
- EndOfLineState3[EndOfLineState3["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail";
128928
- EndOfLineState3[EndOfLineState3["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition";
128929
- return EndOfLineState3;
129029
+ EndOfLineState = /* @__PURE__ */ ((EndOfLineState2) => {
129030
+ EndOfLineState2[EndOfLineState2["None"] = 0] = "None";
129031
+ EndOfLineState2[EndOfLineState2["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia";
129032
+ EndOfLineState2[EndOfLineState2["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral";
129033
+ EndOfLineState2[EndOfLineState2["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral";
129034
+ EndOfLineState2[EndOfLineState2["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate";
129035
+ EndOfLineState2[EndOfLineState2["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail";
129036
+ EndOfLineState2[EndOfLineState2["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition";
129037
+ return EndOfLineState2;
128930
129038
  })(EndOfLineState || {});
128931
129039
  TokenClass = /* @__PURE__ */ ((TokenClass2) => {
128932
129040
  TokenClass2[TokenClass2["Punctuation"] = 0] = "Punctuation";
@@ -144058,933 +144166,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
144058
144166
  }
144059
144167
  });
144060
144168
 
144061
- // src/services/shims.ts
144062
- function logInternalError(logger, err) {
144063
- if (logger) {
144064
- logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message);
144065
- }
144066
- }
144067
- function simpleForwardCall(logger, actionDescription2, action, logPerformance) {
144068
- let start;
144069
- if (logPerformance) {
144070
- logger.log(actionDescription2);
144071
- start = timestamp();
144072
- }
144073
- const result = action();
144074
- if (logPerformance) {
144075
- const end = timestamp();
144076
- logger.log(`${actionDescription2} completed in ${end - start} msec`);
144077
- if (isString(result)) {
144078
- let str = result;
144079
- if (str.length > 128) {
144080
- str = str.substring(0, 128) + "...";
144081
- }
144082
- logger.log(` result.length=${str.length}, result='${JSON.stringify(str)}'`);
144083
- }
144084
- }
144085
- return result;
144086
- }
144087
- function forwardJSONCall(logger, actionDescription2, action, logPerformance) {
144088
- return forwardCall(
144089
- logger,
144090
- actionDescription2,
144091
- /*returnJson*/
144092
- true,
144093
- action,
144094
- logPerformance
144095
- );
144096
- }
144097
- function forwardCall(logger, actionDescription2, returnJson, action, logPerformance) {
144098
- try {
144099
- const result = simpleForwardCall(logger, actionDescription2, action, logPerformance);
144100
- return returnJson ? JSON.stringify({ result }) : result;
144101
- } catch (err) {
144102
- if (err instanceof OperationCanceledException) {
144103
- return JSON.stringify({ canceled: true });
144104
- }
144105
- logInternalError(logger, err);
144106
- err.description = actionDescription2;
144107
- return JSON.stringify({ error: err });
144108
- }
144109
- }
144110
- function realizeDiagnostics(diagnostics, newLine) {
144111
- return diagnostics.map((d) => realizeDiagnostic(d, newLine));
144112
- }
144113
- function realizeDiagnostic(diagnostic, newLine) {
144114
- return {
144115
- message: flattenDiagnosticMessageText(diagnostic.messageText, newLine),
144116
- start: diagnostic.start,
144117
- // TODO: GH#18217
144118
- length: diagnostic.length,
144119
- // TODO: GH#18217
144120
- category: diagnosticCategoryName(diagnostic),
144121
- code: diagnostic.code,
144122
- reportsUnnecessary: diagnostic.reportsUnnecessary,
144123
- reportsDeprecated: diagnostic.reportsDeprecated
144124
- };
144125
- }
144126
- function convertClassifications(classifications) {
144127
- return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState };
144128
- }
144129
- var debugObjectHost, ScriptSnapshotShimAdapter, LanguageServiceShimHostAdapter, CoreServicesShimHostAdapter, ShimBase, LanguageServiceShimObject, ClassifierShimObject, CoreServicesShimObject, TypeScriptServicesFactory;
144130
- var init_shims = __esm({
144131
- "src/services/shims.ts"() {
144132
- "use strict";
144133
- init_ts4();
144134
- debugObjectHost = function() {
144135
- return this;
144136
- }();
144137
- ScriptSnapshotShimAdapter = class {
144138
- constructor(scriptSnapshotShim) {
144139
- this.scriptSnapshotShim = scriptSnapshotShim;
144140
- }
144141
- getText(start, end) {
144142
- return this.scriptSnapshotShim.getText(start, end);
144143
- }
144144
- getLength() {
144145
- return this.scriptSnapshotShim.getLength();
144146
- }
144147
- getChangeRange(oldSnapshot) {
144148
- const oldSnapshotShim = oldSnapshot;
144149
- const encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim);
144150
- if (encoded === null) {
144151
- return null;
144152
- }
144153
- const decoded = JSON.parse(encoded);
144154
- return createTextChangeRange(
144155
- createTextSpan(decoded.span.start, decoded.span.length),
144156
- decoded.newLength
144157
- );
144158
- }
144159
- dispose() {
144160
- if ("dispose" in this.scriptSnapshotShim) {
144161
- this.scriptSnapshotShim.dispose();
144162
- }
144163
- }
144164
- };
144165
- LanguageServiceShimHostAdapter = class {
144166
- constructor(shimHost) {
144167
- this.shimHost = shimHost;
144168
- this.loggingEnabled = false;
144169
- this.tracingEnabled = false;
144170
- if ("getModuleResolutionsForFile" in this.shimHost) {
144171
- this.resolveModuleNames = (moduleNames, containingFile) => {
144172
- const resolutionsInFile = JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile));
144173
- return map(moduleNames, (name) => {
144174
- const result = getProperty(resolutionsInFile, name);
144175
- return result ? { resolvedFileName: result, extension: extensionFromPath(result), isExternalLibraryImport: false } : void 0;
144176
- });
144177
- };
144178
- }
144179
- if ("directoryExists" in this.shimHost) {
144180
- this.directoryExists = (directoryName) => this.shimHost.directoryExists(directoryName);
144181
- }
144182
- if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) {
144183
- this.resolveTypeReferenceDirectives = (typeDirectiveNames, containingFile) => {
144184
- const typeDirectivesForFile = JSON.parse(this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile));
144185
- return map(typeDirectiveNames, (name) => getProperty(typeDirectivesForFile, isString(name) ? name : toFileNameLowerCase(name.fileName)));
144186
- };
144187
- }
144188
- if ("jsDocParsingMode" in this.shimHost) {
144189
- this.jsDocParsingMode = this.shimHost.jsDocParsingMode;
144190
- }
144191
- }
144192
- log(s) {
144193
- if (this.loggingEnabled) {
144194
- this.shimHost.log(s);
144195
- }
144196
- }
144197
- trace(s) {
144198
- if (this.tracingEnabled) {
144199
- this.shimHost.trace(s);
144200
- }
144201
- }
144202
- error(s) {
144203
- this.shimHost.error(s);
144204
- }
144205
- getProjectVersion() {
144206
- if (!this.shimHost.getProjectVersion) {
144207
- return void 0;
144208
- }
144209
- return this.shimHost.getProjectVersion();
144210
- }
144211
- getTypeRootsVersion() {
144212
- if (!this.shimHost.getTypeRootsVersion) {
144213
- return 0;
144214
- }
144215
- return this.shimHost.getTypeRootsVersion();
144216
- }
144217
- useCaseSensitiveFileNames() {
144218
- return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
144219
- }
144220
- getCompilationSettings() {
144221
- const settingsJson = this.shimHost.getCompilationSettings();
144222
- if (settingsJson === null || settingsJson === "") {
144223
- throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
144224
- }
144225
- const compilerOptions = JSON.parse(settingsJson);
144226
- compilerOptions.allowNonTsExtensions = true;
144227
- return compilerOptions;
144228
- }
144229
- getScriptFileNames() {
144230
- const encoded = this.shimHost.getScriptFileNames();
144231
- return JSON.parse(encoded);
144232
- }
144233
- getScriptSnapshot(fileName) {
144234
- const scriptSnapshot = this.shimHost.getScriptSnapshot(fileName);
144235
- return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot);
144236
- }
144237
- getScriptKind(fileName) {
144238
- if ("getScriptKind" in this.shimHost) {
144239
- return this.shimHost.getScriptKind(fileName);
144240
- } else {
144241
- return 0 /* Unknown */;
144242
- }
144243
- }
144244
- getScriptVersion(fileName) {
144245
- return this.shimHost.getScriptVersion(fileName);
144246
- }
144247
- getLocalizedDiagnosticMessages() {
144248
- const diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages();
144249
- if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") {
144250
- return null;
144251
- }
144252
- try {
144253
- return JSON.parse(diagnosticMessagesJson);
144254
- } catch (e) {
144255
- this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format");
144256
- return null;
144257
- }
144258
- }
144259
- getCancellationToken() {
144260
- const hostCancellationToken = this.shimHost.getCancellationToken();
144261
- return new ThrottledCancellationToken(hostCancellationToken);
144262
- }
144263
- getCurrentDirectory() {
144264
- return this.shimHost.getCurrentDirectory();
144265
- }
144266
- getDirectories(path) {
144267
- return JSON.parse(this.shimHost.getDirectories(path));
144268
- }
144269
- getDefaultLibFileName(options) {
144270
- return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
144271
- }
144272
- readDirectory(path, extensions, exclude, include, depth) {
144273
- const pattern = getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory());
144274
- return JSON.parse(this.shimHost.readDirectory(
144275
- path,
144276
- JSON.stringify(extensions),
144277
- JSON.stringify(pattern.basePaths),
144278
- pattern.excludePattern,
144279
- pattern.includeFilePattern,
144280
- pattern.includeDirectoryPattern,
144281
- depth
144282
- ));
144283
- }
144284
- readFile(path, encoding) {
144285
- return this.shimHost.readFile(path, encoding);
144286
- }
144287
- fileExists(path) {
144288
- return this.shimHost.fileExists(path);
144289
- }
144290
- };
144291
- CoreServicesShimHostAdapter = class {
144292
- constructor(shimHost) {
144293
- this.shimHost = shimHost;
144294
- this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
144295
- if ("directoryExists" in this.shimHost) {
144296
- this.directoryExists = (directoryName) => this.shimHost.directoryExists(directoryName);
144297
- } else {
144298
- this.directoryExists = void 0;
144299
- }
144300
- if ("realpath" in this.shimHost) {
144301
- this.realpath = (path) => this.shimHost.realpath(path);
144302
- } else {
144303
- this.realpath = void 0;
144304
- }
144305
- }
144306
- readDirectory(rootDir, extensions, exclude, include, depth) {
144307
- const pattern = getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory());
144308
- return JSON.parse(this.shimHost.readDirectory(
144309
- rootDir,
144310
- JSON.stringify(extensions),
144311
- JSON.stringify(pattern.basePaths),
144312
- pattern.excludePattern,
144313
- pattern.includeFilePattern,
144314
- pattern.includeDirectoryPattern,
144315
- depth
144316
- ));
144317
- }
144318
- fileExists(fileName) {
144319
- return this.shimHost.fileExists(fileName);
144320
- }
144321
- readFile(fileName) {
144322
- return this.shimHost.readFile(fileName);
144323
- }
144324
- getDirectories(path) {
144325
- return JSON.parse(this.shimHost.getDirectories(path));
144326
- }
144327
- };
144328
- ShimBase = class {
144329
- constructor(factory2) {
144330
- this.factory = factory2;
144331
- factory2.registerShim(this);
144332
- }
144333
- dispose(_dummy) {
144334
- this.factory.unregisterShim(this);
144335
- }
144336
- };
144337
- LanguageServiceShimObject = class extends ShimBase {
144338
- constructor(factory2, host, languageService) {
144339
- super(factory2);
144340
- this.host = host;
144341
- this.languageService = languageService;
144342
- this.logPerformance = false;
144343
- this.logger = this.host;
144344
- }
144345
- forwardJSONCall(actionDescription2, action) {
144346
- return forwardJSONCall(this.logger, actionDescription2, action, this.logPerformance);
144347
- }
144348
- /// DISPOSE
144349
- /**
144350
- * Ensure (almost) deterministic release of internal Javascript resources when
144351
- * some external native objects holds onto us (e.g. Com/Interop).
144352
- */
144353
- dispose(dummy) {
144354
- this.logger.log("dispose()");
144355
- this.languageService.dispose();
144356
- this.languageService = null;
144357
- if (debugObjectHost && debugObjectHost.CollectGarbage) {
144358
- debugObjectHost.CollectGarbage();
144359
- this.logger.log("CollectGarbage()");
144360
- }
144361
- this.logger = null;
144362
- super.dispose(dummy);
144363
- }
144364
- /// REFRESH
144365
- /**
144366
- * Update the list of scripts known to the compiler
144367
- */
144368
- refresh(throwOnError) {
144369
- this.forwardJSONCall(
144370
- `refresh(${throwOnError})`,
144371
- () => null
144372
- // eslint-disable-line no-null/no-null
144373
- );
144374
- }
144375
- cleanupSemanticCache() {
144376
- this.forwardJSONCall(
144377
- "cleanupSemanticCache()",
144378
- () => {
144379
- this.languageService.cleanupSemanticCache();
144380
- return null;
144381
- }
144382
- );
144383
- }
144384
- realizeDiagnostics(diagnostics) {
144385
- const newLine = getNewLineOrDefaultFromHost(
144386
- this.host,
144387
- /*formatSettings*/
144388
- void 0
144389
- );
144390
- return realizeDiagnostics(diagnostics, newLine);
144391
- }
144392
- getSyntacticClassifications(fileName, start, length2) {
144393
- return this.forwardJSONCall(
144394
- `getSyntacticClassifications('${fileName}', ${start}, ${length2})`,
144395
- () => this.languageService.getSyntacticClassifications(fileName, createTextSpan(start, length2))
144396
- );
144397
- }
144398
- getSemanticClassifications(fileName, start, length2) {
144399
- return this.forwardJSONCall(
144400
- `getSemanticClassifications('${fileName}', ${start}, ${length2})`,
144401
- () => this.languageService.getSemanticClassifications(fileName, createTextSpan(start, length2))
144402
- );
144403
- }
144404
- getEncodedSyntacticClassifications(fileName, start, length2) {
144405
- return this.forwardJSONCall(
144406
- `getEncodedSyntacticClassifications('${fileName}', ${start}, ${length2})`,
144407
- // directly serialize the spans out to a string. This is much faster to decode
144408
- // on the managed side versus a full JSON array.
144409
- () => convertClassifications(this.languageService.getEncodedSyntacticClassifications(fileName, createTextSpan(start, length2)))
144410
- );
144411
- }
144412
- getEncodedSemanticClassifications(fileName, start, length2) {
144413
- return this.forwardJSONCall(
144414
- `getEncodedSemanticClassifications('${fileName}', ${start}, ${length2})`,
144415
- // directly serialize the spans out to a string. This is much faster to decode
144416
- // on the managed side versus a full JSON array.
144417
- () => convertClassifications(this.languageService.getEncodedSemanticClassifications(fileName, createTextSpan(start, length2)))
144418
- );
144419
- }
144420
- getSyntacticDiagnostics(fileName) {
144421
- return this.forwardJSONCall(
144422
- `getSyntacticDiagnostics('${fileName}')`,
144423
- () => {
144424
- const diagnostics = this.languageService.getSyntacticDiagnostics(fileName);
144425
- return this.realizeDiagnostics(diagnostics);
144426
- }
144427
- );
144428
- }
144429
- getSemanticDiagnostics(fileName) {
144430
- return this.forwardJSONCall(
144431
- `getSemanticDiagnostics('${fileName}')`,
144432
- () => {
144433
- const diagnostics = this.languageService.getSemanticDiagnostics(fileName);
144434
- return this.realizeDiagnostics(diagnostics);
144435
- }
144436
- );
144437
- }
144438
- getSuggestionDiagnostics(fileName) {
144439
- return this.forwardJSONCall(`getSuggestionDiagnostics('${fileName}')`, () => this.realizeDiagnostics(this.languageService.getSuggestionDiagnostics(fileName)));
144440
- }
144441
- getCompilerOptionsDiagnostics() {
144442
- return this.forwardJSONCall(
144443
- "getCompilerOptionsDiagnostics()",
144444
- () => {
144445
- const diagnostics = this.languageService.getCompilerOptionsDiagnostics();
144446
- return this.realizeDiagnostics(diagnostics);
144447
- }
144448
- );
144449
- }
144450
- /// QUICKINFO
144451
- /**
144452
- * Computes a string representation of the type at the requested position
144453
- * in the active file.
144454
- */
144455
- getQuickInfoAtPosition(fileName, position) {
144456
- return this.forwardJSONCall(
144457
- `getQuickInfoAtPosition('${fileName}', ${position})`,
144458
- () => this.languageService.getQuickInfoAtPosition(fileName, position)
144459
- );
144460
- }
144461
- /// NAMEORDOTTEDNAMESPAN
144462
- /**
144463
- * Computes span information of the name or dotted name at the requested position
144464
- * in the active file.
144465
- */
144466
- getNameOrDottedNameSpan(fileName, startPos, endPos) {
144467
- return this.forwardJSONCall(
144468
- `getNameOrDottedNameSpan('${fileName}', ${startPos}, ${endPos})`,
144469
- () => this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos)
144470
- );
144471
- }
144472
- /**
144473
- * STATEMENTSPAN
144474
- * Computes span information of statement at the requested position in the active file.
144475
- */
144476
- getBreakpointStatementAtPosition(fileName, position) {
144477
- return this.forwardJSONCall(
144478
- `getBreakpointStatementAtPosition('${fileName}', ${position})`,
144479
- () => this.languageService.getBreakpointStatementAtPosition(fileName, position)
144480
- );
144481
- }
144482
- /// SIGNATUREHELP
144483
- getSignatureHelpItems(fileName, position, options) {
144484
- return this.forwardJSONCall(
144485
- `getSignatureHelpItems('${fileName}', ${position})`,
144486
- () => this.languageService.getSignatureHelpItems(fileName, position, options)
144487
- );
144488
- }
144489
- /// GOTO DEFINITION
144490
- /**
144491
- * Computes the definition location and file for the symbol
144492
- * at the requested position.
144493
- */
144494
- getDefinitionAtPosition(fileName, position) {
144495
- return this.forwardJSONCall(
144496
- `getDefinitionAtPosition('${fileName}', ${position})`,
144497
- () => this.languageService.getDefinitionAtPosition(fileName, position)
144498
- );
144499
- }
144500
- /**
144501
- * Computes the definition location and file for the symbol
144502
- * at the requested position.
144503
- */
144504
- getDefinitionAndBoundSpan(fileName, position) {
144505
- return this.forwardJSONCall(
144506
- `getDefinitionAndBoundSpan('${fileName}', ${position})`,
144507
- () => this.languageService.getDefinitionAndBoundSpan(fileName, position)
144508
- );
144509
- }
144510
- /// GOTO Type
144511
- /**
144512
- * Computes the definition location of the type of the symbol
144513
- * at the requested position.
144514
- */
144515
- getTypeDefinitionAtPosition(fileName, position) {
144516
- return this.forwardJSONCall(
144517
- `getTypeDefinitionAtPosition('${fileName}', ${position})`,
144518
- () => this.languageService.getTypeDefinitionAtPosition(fileName, position)
144519
- );
144520
- }
144521
- /// GOTO Implementation
144522
- /**
144523
- * Computes the implementation location of the symbol
144524
- * at the requested position.
144525
- */
144526
- getImplementationAtPosition(fileName, position) {
144527
- return this.forwardJSONCall(
144528
- `getImplementationAtPosition('${fileName}', ${position})`,
144529
- () => this.languageService.getImplementationAtPosition(fileName, position)
144530
- );
144531
- }
144532
- getRenameInfo(fileName, position, preferences) {
144533
- return this.forwardJSONCall(
144534
- `getRenameInfo('${fileName}', ${position})`,
144535
- () => this.languageService.getRenameInfo(fileName, position, preferences)
144536
- );
144537
- }
144538
- getSmartSelectionRange(fileName, position) {
144539
- return this.forwardJSONCall(
144540
- `getSmartSelectionRange('${fileName}', ${position})`,
144541
- () => this.languageService.getSmartSelectionRange(fileName, position)
144542
- );
144543
- }
144544
- findRenameLocations(fileName, position, findInStrings, findInComments, preferences) {
144545
- return this.forwardJSONCall(
144546
- `findRenameLocations('${fileName}', ${position}, ${findInStrings}, ${findInComments})`,
144547
- () => this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, preferences)
144548
- );
144549
- }
144550
- /// GET BRACE MATCHING
144551
- getBraceMatchingAtPosition(fileName, position) {
144552
- return this.forwardJSONCall(
144553
- `getBraceMatchingAtPosition('${fileName}', ${position})`,
144554
- () => this.languageService.getBraceMatchingAtPosition(fileName, position)
144555
- );
144556
- }
144557
- isValidBraceCompletionAtPosition(fileName, position, openingBrace) {
144558
- return this.forwardJSONCall(
144559
- `isValidBraceCompletionAtPosition('${fileName}', ${position}, ${openingBrace})`,
144560
- () => this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace)
144561
- );
144562
- }
144563
- getSpanOfEnclosingComment(fileName, position, onlyMultiLine) {
144564
- return this.forwardJSONCall(
144565
- `getSpanOfEnclosingComment('${fileName}', ${position})`,
144566
- () => this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine)
144567
- );
144568
- }
144569
- /// GET SMART INDENT
144570
- getIndentationAtPosition(fileName, position, options) {
144571
- return this.forwardJSONCall(
144572
- `getIndentationAtPosition('${fileName}', ${position})`,
144573
- () => {
144574
- const localOptions = JSON.parse(options);
144575
- return this.languageService.getIndentationAtPosition(fileName, position, localOptions);
144576
- }
144577
- );
144578
- }
144579
- /// GET REFERENCES
144580
- getReferencesAtPosition(fileName, position) {
144581
- return this.forwardJSONCall(
144582
- `getReferencesAtPosition('${fileName}', ${position})`,
144583
- () => this.languageService.getReferencesAtPosition(fileName, position)
144584
- );
144585
- }
144586
- findReferences(fileName, position) {
144587
- return this.forwardJSONCall(
144588
- `findReferences('${fileName}', ${position})`,
144589
- () => this.languageService.findReferences(fileName, position)
144590
- );
144591
- }
144592
- getFileReferences(fileName) {
144593
- return this.forwardJSONCall(
144594
- `getFileReferences('${fileName})`,
144595
- () => this.languageService.getFileReferences(fileName)
144596
- );
144597
- }
144598
- getDocumentHighlights(fileName, position, filesToSearch) {
144599
- return this.forwardJSONCall(
144600
- `getDocumentHighlights('${fileName}', ${position})`,
144601
- () => {
144602
- const results = this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch));
144603
- const normalizedName = toFileNameLowerCase(normalizeSlashes(fileName));
144604
- return filter(results, (r) => toFileNameLowerCase(normalizeSlashes(r.fileName)) === normalizedName);
144605
- }
144606
- );
144607
- }
144608
- /// COMPLETION LISTS
144609
- /**
144610
- * Get a string based representation of the completions
144611
- * to provide at the given source position and providing a member completion
144612
- * list if requested.
144613
- */
144614
- getCompletionsAtPosition(fileName, position, preferences, formattingSettings) {
144615
- return this.forwardJSONCall(
144616
- `getCompletionsAtPosition('${fileName}', ${position}, ${preferences}, ${formattingSettings})`,
144617
- () => this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings)
144618
- );
144619
- }
144620
- /** Get a string based representation of a completion list entry details */
144621
- getCompletionEntryDetails(fileName, position, entryName, formatOptions, source, preferences, data) {
144622
- return this.forwardJSONCall(
144623
- `getCompletionEntryDetails('${fileName}', ${position}, '${entryName}')`,
144624
- () => {
144625
- const localOptions = formatOptions === void 0 ? void 0 : JSON.parse(formatOptions);
144626
- return this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data);
144627
- }
144628
- );
144629
- }
144630
- getFormattingEditsForRange(fileName, start, end, options) {
144631
- return this.forwardJSONCall(
144632
- `getFormattingEditsForRange('${fileName}', ${start}, ${end})`,
144633
- () => {
144634
- const localOptions = JSON.parse(options);
144635
- return this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions);
144636
- }
144637
- );
144638
- }
144639
- getFormattingEditsForDocument(fileName, options) {
144640
- return this.forwardJSONCall(
144641
- `getFormattingEditsForDocument('${fileName}')`,
144642
- () => {
144643
- const localOptions = JSON.parse(options);
144644
- return this.languageService.getFormattingEditsForDocument(fileName, localOptions);
144645
- }
144646
- );
144647
- }
144648
- getFormattingEditsAfterKeystroke(fileName, position, key, options) {
144649
- return this.forwardJSONCall(
144650
- `getFormattingEditsAfterKeystroke('${fileName}', ${position}, '${key}')`,
144651
- () => {
144652
- const localOptions = JSON.parse(options);
144653
- return this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions);
144654
- }
144655
- );
144656
- }
144657
- getDocCommentTemplateAtPosition(fileName, position, options, formatOptions) {
144658
- return this.forwardJSONCall(
144659
- `getDocCommentTemplateAtPosition('${fileName}', ${position})`,
144660
- () => this.languageService.getDocCommentTemplateAtPosition(fileName, position, options, formatOptions)
144661
- );
144662
- }
144663
- /// NAVIGATE TO
144664
- /** Return a list of symbols that are interesting to navigate to */
144665
- getNavigateToItems(searchValue, maxResultCount, fileName) {
144666
- return this.forwardJSONCall(
144667
- `getNavigateToItems('${searchValue}', ${maxResultCount}, ${fileName})`,
144668
- () => this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName)
144669
- );
144670
- }
144671
- getNavigationBarItems(fileName) {
144672
- return this.forwardJSONCall(
144673
- `getNavigationBarItems('${fileName}')`,
144674
- () => this.languageService.getNavigationBarItems(fileName)
144675
- );
144676
- }
144677
- getNavigationTree(fileName) {
144678
- return this.forwardJSONCall(
144679
- `getNavigationTree('${fileName}')`,
144680
- () => this.languageService.getNavigationTree(fileName)
144681
- );
144682
- }
144683
- getOutliningSpans(fileName) {
144684
- return this.forwardJSONCall(
144685
- `getOutliningSpans('${fileName}')`,
144686
- () => this.languageService.getOutliningSpans(fileName)
144687
- );
144688
- }
144689
- getTodoComments(fileName, descriptors) {
144690
- return this.forwardJSONCall(
144691
- `getTodoComments('${fileName}')`,
144692
- () => this.languageService.getTodoComments(fileName, JSON.parse(descriptors))
144693
- );
144694
- }
144695
- /// CALL HIERARCHY
144696
- prepareCallHierarchy(fileName, position) {
144697
- return this.forwardJSONCall(
144698
- `prepareCallHierarchy('${fileName}', ${position})`,
144699
- () => this.languageService.prepareCallHierarchy(fileName, position)
144700
- );
144701
- }
144702
- provideCallHierarchyIncomingCalls(fileName, position) {
144703
- return this.forwardJSONCall(
144704
- `provideCallHierarchyIncomingCalls('${fileName}', ${position})`,
144705
- () => this.languageService.provideCallHierarchyIncomingCalls(fileName, position)
144706
- );
144707
- }
144708
- provideCallHierarchyOutgoingCalls(fileName, position) {
144709
- return this.forwardJSONCall(
144710
- `provideCallHierarchyOutgoingCalls('${fileName}', ${position})`,
144711
- () => this.languageService.provideCallHierarchyOutgoingCalls(fileName, position)
144712
- );
144713
- }
144714
- provideInlayHints(fileName, span, preference) {
144715
- return this.forwardJSONCall(
144716
- `provideInlayHints('${fileName}', '${JSON.stringify(span)}', ${JSON.stringify(preference)})`,
144717
- () => this.languageService.provideInlayHints(fileName, span, preference)
144718
- );
144719
- }
144720
- /// Emit
144721
- getEmitOutput(fileName) {
144722
- return this.forwardJSONCall(
144723
- `getEmitOutput('${fileName}')`,
144724
- () => {
144725
- const { diagnostics, ...rest } = this.languageService.getEmitOutput(fileName);
144726
- return { ...rest, diagnostics: this.realizeDiagnostics(diagnostics) };
144727
- }
144728
- );
144729
- }
144730
- getEmitOutputObject(fileName) {
144731
- return forwardCall(
144732
- this.logger,
144733
- `getEmitOutput('${fileName}')`,
144734
- /*returnJson*/
144735
- false,
144736
- () => this.languageService.getEmitOutput(fileName),
144737
- this.logPerformance
144738
- );
144739
- }
144740
- toggleLineComment(fileName, textRange) {
144741
- return this.forwardJSONCall(
144742
- `toggleLineComment('${fileName}', '${JSON.stringify(textRange)}')`,
144743
- () => this.languageService.toggleLineComment(fileName, textRange)
144744
- );
144745
- }
144746
- toggleMultilineComment(fileName, textRange) {
144747
- return this.forwardJSONCall(
144748
- `toggleMultilineComment('${fileName}', '${JSON.stringify(textRange)}')`,
144749
- () => this.languageService.toggleMultilineComment(fileName, textRange)
144750
- );
144751
- }
144752
- commentSelection(fileName, textRange) {
144753
- return this.forwardJSONCall(
144754
- `commentSelection('${fileName}', '${JSON.stringify(textRange)}')`,
144755
- () => this.languageService.commentSelection(fileName, textRange)
144756
- );
144757
- }
144758
- uncommentSelection(fileName, textRange) {
144759
- return this.forwardJSONCall(
144760
- `uncommentSelection('${fileName}', '${JSON.stringify(textRange)}')`,
144761
- () => this.languageService.uncommentSelection(fileName, textRange)
144762
- );
144763
- }
144764
- };
144765
- ClassifierShimObject = class extends ShimBase {
144766
- constructor(factory2, logger) {
144767
- super(factory2);
144768
- this.logger = logger;
144769
- this.logPerformance = false;
144770
- this.classifier = createClassifier();
144771
- }
144772
- getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent = false) {
144773
- return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", () => convertClassifications(this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)), this.logPerformance);
144774
- }
144775
- /// COLORIZATION
144776
- getClassificationsForLine(text, lexState, classifyKeywordsInGenerics = false) {
144777
- const classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics);
144778
- let result = "";
144779
- for (const item of classification.entries) {
144780
- result += item.length + "\n";
144781
- result += item.classification + "\n";
144782
- }
144783
- result += classification.finalLexState;
144784
- return result;
144785
- }
144786
- };
144787
- CoreServicesShimObject = class extends ShimBase {
144788
- constructor(factory2, logger, host) {
144789
- super(factory2);
144790
- this.logger = logger;
144791
- this.host = host;
144792
- this.logPerformance = false;
144793
- }
144794
- forwardJSONCall(actionDescription2, action) {
144795
- return forwardJSONCall(this.logger, actionDescription2, action, this.logPerformance);
144796
- }
144797
- resolveModuleName(fileName, moduleName, compilerOptionsJson) {
144798
- return this.forwardJSONCall(`resolveModuleName('${fileName}')`, () => {
144799
- const compilerOptions = JSON.parse(compilerOptionsJson);
144800
- const result = resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host);
144801
- let resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : void 0;
144802
- if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) {
144803
- resolvedFileName = void 0;
144804
- }
144805
- return {
144806
- resolvedFileName,
144807
- failedLookupLocations: result.failedLookupLocations,
144808
- affectingLocations: result.affectingLocations
144809
- };
144810
- });
144811
- }
144812
- resolveTypeReferenceDirective(fileName, typeReferenceDirective, compilerOptionsJson) {
144813
- return this.forwardJSONCall(`resolveTypeReferenceDirective(${fileName})`, () => {
144814
- const compilerOptions = JSON.parse(compilerOptionsJson);
144815
- const result = resolveTypeReferenceDirective(typeReferenceDirective, normalizeSlashes(fileName), compilerOptions, this.host);
144816
- return {
144817
- resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : void 0,
144818
- primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true,
144819
- failedLookupLocations: result.failedLookupLocations
144820
- };
144821
- });
144822
- }
144823
- getPreProcessedFileInfo(fileName, sourceTextSnapshot) {
144824
- return this.forwardJSONCall(
144825
- `getPreProcessedFileInfo('${fileName}')`,
144826
- () => {
144827
- const result = preProcessFile(
144828
- getSnapshotText(sourceTextSnapshot),
144829
- /*readImportFiles*/
144830
- true,
144831
- /*detectJavaScriptImports*/
144832
- true
144833
- );
144834
- return {
144835
- referencedFiles: this.convertFileReferences(result.referencedFiles),
144836
- importedFiles: this.convertFileReferences(result.importedFiles),
144837
- ambientExternalModules: result.ambientExternalModules,
144838
- isLibFile: result.isLibFile,
144839
- typeReferenceDirectives: this.convertFileReferences(result.typeReferenceDirectives),
144840
- libReferenceDirectives: this.convertFileReferences(result.libReferenceDirectives)
144841
- };
144842
- }
144843
- );
144844
- }
144845
- getAutomaticTypeDirectiveNames(compilerOptionsJson) {
144846
- return this.forwardJSONCall(
144847
- `getAutomaticTypeDirectiveNames('${compilerOptionsJson}')`,
144848
- () => {
144849
- const compilerOptions = JSON.parse(compilerOptionsJson);
144850
- return getAutomaticTypeDirectiveNames(compilerOptions, this.host);
144851
- }
144852
- );
144853
- }
144854
- convertFileReferences(refs) {
144855
- if (!refs) {
144856
- return void 0;
144857
- }
144858
- const result = [];
144859
- for (const ref of refs) {
144860
- result.push({
144861
- path: normalizeSlashes(ref.fileName),
144862
- position: ref.pos,
144863
- length: ref.end - ref.pos
144864
- });
144865
- }
144866
- return result;
144867
- }
144868
- getTSConfigFileInfo(fileName, sourceTextSnapshot) {
144869
- return this.forwardJSONCall(
144870
- `getTSConfigFileInfo('${fileName}')`,
144871
- () => {
144872
- const result = parseJsonText(fileName, getSnapshotText(sourceTextSnapshot));
144873
- const normalizedFileName = normalizeSlashes(fileName);
144874
- const configFile = parseJsonSourceFileConfigFileContent(
144875
- result,
144876
- this.host,
144877
- getDirectoryPath(normalizedFileName),
144878
- /*existingOptions*/
144879
- {},
144880
- normalizedFileName
144881
- );
144882
- return {
144883
- options: configFile.options,
144884
- typeAcquisition: configFile.typeAcquisition,
144885
- files: configFile.fileNames,
144886
- raw: configFile.raw,
144887
- errors: realizeDiagnostics([...result.parseDiagnostics, ...configFile.errors], "\r\n")
144888
- };
144889
- }
144890
- );
144891
- }
144892
- getDefaultCompilationSettings() {
144893
- return this.forwardJSONCall(
144894
- "getDefaultCompilationSettings()",
144895
- () => getDefaultCompilerOptions2()
144896
- );
144897
- }
144898
- discoverTypings(discoverTypingsJson) {
144899
- const getCanonicalFileName = createGetCanonicalFileName(
144900
- /*useCaseSensitiveFileNames*/
144901
- false
144902
- );
144903
- return this.forwardJSONCall("discoverTypings()", () => {
144904
- const info = JSON.parse(discoverTypingsJson);
144905
- if (this.safeList === void 0) {
144906
- this.safeList = ts_JsTyping_exports.loadSafeList(this.host, toPath(info.safeListPath, info.safeListPath, getCanonicalFileName));
144907
- }
144908
- return ts_JsTyping_exports.discoverTypings(
144909
- this.host,
144910
- (msg) => this.logger.log(msg),
144911
- info.fileNames,
144912
- toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName),
144913
- this.safeList,
144914
- info.packageNameToTypingLocation,
144915
- info.typeAcquisition,
144916
- info.unresolvedImports,
144917
- info.typesRegistry,
144918
- emptyOptions
144919
- );
144920
- });
144921
- }
144922
- };
144923
- TypeScriptServicesFactory = class {
144924
- constructor() {
144925
- this._shims = [];
144926
- }
144927
- /*
144928
- * Returns script API version.
144929
- */
144930
- getServicesVersion() {
144931
- return servicesVersion;
144932
- }
144933
- createLanguageServiceShim(host) {
144934
- try {
144935
- if (this.documentRegistry === void 0) {
144936
- this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory());
144937
- }
144938
- const hostAdapter = new LanguageServiceShimHostAdapter(host);
144939
- const languageService = createLanguageService(
144940
- hostAdapter,
144941
- this.documentRegistry,
144942
- /*syntaxOnlyOrLanguageServiceMode*/
144943
- false
144944
- );
144945
- return new LanguageServiceShimObject(this, host, languageService);
144946
- } catch (err) {
144947
- logInternalError(host, err);
144948
- throw err;
144949
- }
144950
- }
144951
- createClassifierShim(logger) {
144952
- try {
144953
- return new ClassifierShimObject(this, logger);
144954
- } catch (err) {
144955
- logInternalError(logger, err);
144956
- throw err;
144957
- }
144958
- }
144959
- createCoreServicesShim(host) {
144960
- try {
144961
- const adapter = new CoreServicesShimHostAdapter(host);
144962
- return new CoreServicesShimObject(this, host, adapter);
144963
- } catch (err) {
144964
- logInternalError(host, err);
144965
- throw err;
144966
- }
144967
- }
144968
- close() {
144969
- clear(this._shims);
144970
- this.documentRegistry = void 0;
144971
- }
144972
- registerShim(shim) {
144973
- this._shims.push(shim);
144974
- }
144975
- unregisterShim(shim) {
144976
- for (let i = 0; i < this._shims.length; i++) {
144977
- if (this._shims[i] === shim) {
144978
- delete this._shims[i];
144979
- return;
144980
- }
144981
- }
144982
- throw new Error("Invalid operation");
144983
- }
144984
- };
144985
- }
144986
- });
144987
-
144988
144169
  // src/services/breakpoints.ts
144989
144170
  function spanInSourceFileAtLocation(sourceFile, position) {
144990
144171
  if (sourceFile.isDeclarationFile) {
@@ -164551,14 +163732,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164551
163732
  if (isModuleReferenceType(declarationType)) {
164552
163733
  return;
164553
163734
  }
164554
- const hints = typeToInlayHintParts(declarationType);
164555
- if (hints) {
164556
- const hintText = typeof hints === "string" ? hints : hints.map((part) => part.text).join("");
163735
+ const hintParts = typeToInlayHintParts(declarationType);
163736
+ if (hintParts) {
163737
+ const hintText = typeof hintParts === "string" ? hintParts : hintParts.map((part) => part.text).join("");
164557
163738
  const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), hintText);
164558
163739
  if (isVariableNameMatchesType) {
164559
163740
  return;
164560
163741
  }
164561
- addTypeHints(hints, decl.name.end);
163742
+ addTypeHints(hintParts, decl.name.end);
164562
163743
  }
164563
163744
  }
164564
163745
  function visitCallOrNewExpression(expr) {
@@ -164666,9 +163847,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164666
163847
  if (isModuleReferenceType(returnType)) {
164667
163848
  return;
164668
163849
  }
164669
- const hint = typeToInlayHintParts(returnType);
164670
- if (hint) {
164671
- addTypeHints(hint, getTypeAnnotationPosition(decl));
163850
+ const hintParts = typeToInlayHintParts(returnType);
163851
+ if (hintParts) {
163852
+ addTypeHints(hintParts, getTypeAnnotationPosition(decl));
164672
163853
  }
164673
163854
  }
164674
163855
  function getTypeAnnotationPosition(decl) {
@@ -164692,14 +163873,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164692
163873
  if (effectiveTypeAnnotation) {
164693
163874
  continue;
164694
163875
  }
164695
- const typeDisplayString = getParameterDeclarationTypeDisplayString(signature.parameters[i]);
164696
- if (!typeDisplayString) {
163876
+ const typeHints = getParameterDeclarationTypeHints(signature.parameters[i]);
163877
+ if (!typeHints) {
164697
163878
  continue;
164698
163879
  }
164699
- addTypeHints(typeDisplayString, param.questionToken ? param.questionToken.end : param.name.end);
163880
+ addTypeHints(typeHints, param.questionToken ? param.questionToken.end : param.name.end);
164700
163881
  }
164701
163882
  }
164702
- function getParameterDeclarationTypeDisplayString(symbol) {
163883
+ function getParameterDeclarationTypeHints(symbol) {
164703
163884
  const valueDeclaration = symbol.valueDeclaration;
164704
163885
  if (!valueDeclaration || !isParameter(valueDeclaration)) {
164705
163886
  return void 0;
@@ -164708,7 +163889,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164708
163889
  if (isModuleReferenceType(signatureParamType)) {
164709
163890
  return void 0;
164710
163891
  }
164711
- return printTypeInSingleLine(signatureParamType);
163892
+ return typeToInlayHintParts(signatureParamType);
164712
163893
  }
164713
163894
  function printTypeInSingleLine(type) {
164714
163895
  const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
@@ -172273,7 +171454,6 @@ ${options.prefix}` : "\n" : options.prefix
172273
171454
  init_transpile();
172274
171455
  init_services();
172275
171456
  init_transform();
172276
- init_shims();
172277
171457
  init_ts_BreakpointResolver();
172278
171458
  init_ts_CallHierarchy();
172279
171459
  init_ts_classifier();
@@ -184049,7 +183229,6 @@ ${e.message}`;
184049
183229
  ConfigFileProgramReloadLevel: () => ConfigFileProgramReloadLevel,
184050
183230
  ContainerFlags: () => ContainerFlags,
184051
183231
  ContextFlags: () => ContextFlags,
184052
- CoreServicesShimHostAdapter: () => CoreServicesShimHostAdapter,
184053
183232
  Debug: () => Debug,
184054
183233
  DiagnosticCategory: () => DiagnosticCategory,
184055
183234
  Diagnostics: () => Diagnostics,
@@ -184098,7 +183277,6 @@ ${e.message}`;
184098
183277
  JsxFlags: () => JsxFlags,
184099
183278
  JsxReferenceKind: () => JsxReferenceKind,
184100
183279
  LanguageServiceMode: () => LanguageServiceMode,
184101
- LanguageServiceShimHostAdapter: () => LanguageServiceShimHostAdapter,
184102
183280
  LanguageVariant: () => LanguageVariant,
184103
183281
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
184104
183282
  ListFormat: () => ListFormat,
@@ -184172,7 +183350,6 @@ ${e.message}`;
184172
183350
  TypeMapKind: () => TypeMapKind,
184173
183351
  TypePredicateKind: () => TypePredicateKind,
184174
183352
  TypeReferenceSerializationKind: () => TypeReferenceSerializationKind,
184175
- TypeScriptServicesFactory: () => TypeScriptServicesFactory,
184176
183353
  UnionReduction: () => UnionReduction,
184177
183354
  UpToDateStatusType: () => UpToDateStatusType,
184178
183355
  VarianceFlags: () => VarianceFlags,
@@ -185244,7 +184421,7 @@ ${e.message}`;
185244
184421
  isClassDeclaration: () => isClassDeclaration,
185245
184422
  isClassElement: () => isClassElement,
185246
184423
  isClassExpression: () => isClassExpression,
185247
- isClassFieldAndNotAutoAccessor: () => isClassFieldAndNotAutoAccessor,
184424
+ isClassInstanceProperty: () => isClassInstanceProperty,
185248
184425
  isClassLike: () => isClassLike,
185249
184426
  isClassMemberModifier: () => isClassMemberModifier,
185250
184427
  isClassNamedEvaluationHelperBlock: () => isClassNamedEvaluationHelperBlock,
@@ -185435,6 +184612,7 @@ ${e.message}`;
185435
184612
  isInsideJsxElementOrAttribute: () => isInsideJsxElementOrAttribute,
185436
184613
  isInsideNodeModules: () => isInsideNodeModules,
185437
184614
  isInsideTemplateLiteral: () => isInsideTemplateLiteral,
184615
+ isInstanceOfExpression: () => isInstanceOfExpression,
185438
184616
  isInstantiatedModule: () => isInstantiatedModule,
185439
184617
  isInterfaceDeclaration: () => isInterfaceDeclaration,
185440
184618
  isInternalDeclaration: () => isInternalDeclaration,
@@ -185692,6 +184870,7 @@ ${e.message}`;
185692
184870
  isReturnStatement: () => isReturnStatement,
185693
184871
  isReturnStatementWithFixablePromiseHandler: () => isReturnStatementWithFixablePromiseHandler,
185694
184872
  isRightSideOfAccessExpression: () => isRightSideOfAccessExpression,
184873
+ isRightSideOfInstanceofExpression: () => isRightSideOfInstanceofExpression,
185695
184874
  isRightSideOfPropertyAccess: () => isRightSideOfPropertyAccess,
185696
184875
  isRightSideOfQualifiedName: () => isRightSideOfQualifiedName,
185697
184876
  isRightSideOfQualifiedNameOrPropertyAccess: () => isRightSideOfQualifiedNameOrPropertyAccess,
@@ -186016,7 +185195,6 @@ ${e.message}`;
186016
185195
  readJson: () => readJson,
186017
185196
  readJsonConfigFile: () => readJsonConfigFile,
186018
185197
  readJsonOrUndefined: () => readJsonOrUndefined,
186019
- realizeDiagnostics: () => realizeDiagnostics,
186020
185198
  reduceEachLeadingCommentRange: () => reduceEachLeadingCommentRange,
186021
185199
  reduceEachTrailingCommentRange: () => reduceEachTrailingCommentRange,
186022
185200
  reduceLeft: () => reduceLeft,
@@ -186458,7 +185636,6 @@ ${e.message}`;
186458
185636
  ConfigFileProgramReloadLevel: () => ConfigFileProgramReloadLevel,
186459
185637
  ContainerFlags: () => ContainerFlags,
186460
185638
  ContextFlags: () => ContextFlags,
186461
- CoreServicesShimHostAdapter: () => CoreServicesShimHostAdapter,
186462
185639
  Debug: () => Debug,
186463
185640
  DiagnosticCategory: () => DiagnosticCategory,
186464
185641
  Diagnostics: () => Diagnostics,
@@ -186507,7 +185684,6 @@ ${e.message}`;
186507
185684
  JsxFlags: () => JsxFlags,
186508
185685
  JsxReferenceKind: () => JsxReferenceKind,
186509
185686
  LanguageServiceMode: () => LanguageServiceMode,
186510
- LanguageServiceShimHostAdapter: () => LanguageServiceShimHostAdapter,
186511
185687
  LanguageVariant: () => LanguageVariant,
186512
185688
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
186513
185689
  ListFormat: () => ListFormat,
@@ -186581,7 +185757,6 @@ ${e.message}`;
186581
185757
  TypeMapKind: () => TypeMapKind,
186582
185758
  TypePredicateKind: () => TypePredicateKind,
186583
185759
  TypeReferenceSerializationKind: () => TypeReferenceSerializationKind,
186584
- TypeScriptServicesFactory: () => TypeScriptServicesFactory,
186585
185760
  UnionReduction: () => UnionReduction,
186586
185761
  UpToDateStatusType: () => UpToDateStatusType,
186587
185762
  VarianceFlags: () => VarianceFlags,
@@ -187653,7 +186828,7 @@ ${e.message}`;
187653
186828
  isClassDeclaration: () => isClassDeclaration,
187654
186829
  isClassElement: () => isClassElement,
187655
186830
  isClassExpression: () => isClassExpression,
187656
- isClassFieldAndNotAutoAccessor: () => isClassFieldAndNotAutoAccessor,
186831
+ isClassInstanceProperty: () => isClassInstanceProperty,
187657
186832
  isClassLike: () => isClassLike,
187658
186833
  isClassMemberModifier: () => isClassMemberModifier,
187659
186834
  isClassNamedEvaluationHelperBlock: () => isClassNamedEvaluationHelperBlock,
@@ -187844,6 +187019,7 @@ ${e.message}`;
187844
187019
  isInsideJsxElementOrAttribute: () => isInsideJsxElementOrAttribute,
187845
187020
  isInsideNodeModules: () => isInsideNodeModules,
187846
187021
  isInsideTemplateLiteral: () => isInsideTemplateLiteral,
187022
+ isInstanceOfExpression: () => isInstanceOfExpression,
187847
187023
  isInstantiatedModule: () => isInstantiatedModule,
187848
187024
  isInterfaceDeclaration: () => isInterfaceDeclaration,
187849
187025
  isInternalDeclaration: () => isInternalDeclaration,
@@ -188101,6 +187277,7 @@ ${e.message}`;
188101
187277
  isReturnStatement: () => isReturnStatement,
188102
187278
  isReturnStatementWithFixablePromiseHandler: () => isReturnStatementWithFixablePromiseHandler,
188103
187279
  isRightSideOfAccessExpression: () => isRightSideOfAccessExpression,
187280
+ isRightSideOfInstanceofExpression: () => isRightSideOfInstanceofExpression,
188104
187281
  isRightSideOfPropertyAccess: () => isRightSideOfPropertyAccess,
188105
187282
  isRightSideOfQualifiedName: () => isRightSideOfQualifiedName,
188106
187283
  isRightSideOfQualifiedNameOrPropertyAccess: () => isRightSideOfQualifiedNameOrPropertyAccess,
@@ -188425,7 +187602,6 @@ ${e.message}`;
188425
187602
  readJson: () => readJson,
188426
187603
  readJsonConfigFile: () => readJsonConfigFile,
188427
187604
  readJsonOrUndefined: () => readJsonOrUndefined,
188428
- realizeDiagnostics: () => realizeDiagnostics,
188429
187605
  reduceEachLeadingCommentRange: () => reduceEachLeadingCommentRange,
188430
187606
  reduceEachTrailingCommentRange: () => reduceEachTrailingCommentRange,
188431
187607
  reduceLeft: () => reduceLeft,