@typescript-deploys/pr-build 5.3.0-pr-55860-30 → 5.3.0-pr-55867-7

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-insiders.20230928`;
38
+ version = `${versionMajorMinor}.0-insiders.20230929`;
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,7 +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_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1: diag(2860, 1 /* Error */, "The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1_2860", "The type of this declaration is ambiguous and may be observed as either '{0}' or '{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."),
7965
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}'."),
7966
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}'."),
7967
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}'."),
@@ -12275,6 +12276,13 @@ ${lanes.join("\n")}
12275
12276
  return isPropertyDeclaration(node) && hasAccessorModifier(node);
12276
12277
  }
12277
12278
  function isClassFieldAndNotAutoAccessor(node) {
12279
+ if (isInJSFile(node) && isExpandoPropertyDeclaration(node)) {
12280
+ return (!isBindableStaticAccessExpression(node) || !isPrototypeAccess(node.expression)) && !isBindableStaticNameExpression(
12281
+ node,
12282
+ /*excludeThisKeyword*/
12283
+ true
12284
+ );
12285
+ }
12278
12286
  return node.parent && isClassLike(node.parent) && isPropertyDeclaration(node) && !hasAccessorModifier(node);
12279
12287
  }
12280
12288
  function isMethodOrAccessor(node) {
@@ -14301,6 +14309,8 @@ ${lanes.join("\n")}
14301
14309
  case 286 /* JsxOpeningElement */:
14302
14310
  case 285 /* JsxSelfClosingElement */:
14303
14311
  return node.tagName;
14312
+ case 226 /* BinaryExpression */:
14313
+ return node.right;
14304
14314
  default:
14305
14315
  return node.expression;
14306
14316
  }
@@ -16878,6 +16888,12 @@ ${lanes.join("\n")}
16878
16888
  function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
16879
16889
  return isQualifiedName(node.parent) && node.parent.right === node || isPropertyAccessExpression(node.parent) && node.parent.name === node || isJSDocMemberName(node.parent) && node.parent.right === node;
16880
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
+ }
16881
16897
  function isEmptyObjectLiteral(expression) {
16882
16898
  return expression.kind === 210 /* ObjectLiteralExpression */ && expression.properties.length === 0;
16883
16899
  }
@@ -46037,7 +46053,7 @@ ${lanes.join("\n")}
46037
46053
  candidates,
46038
46054
  /*argumentCount*/
46039
46055
  void 0,
46040
- 32 /* IsForStringLiteralArgumentCompletions */
46056
+ 0 /* Normal */
46041
46057
  ));
46042
46058
  for (const candidate of candidates) {
46043
46059
  candidatesSet.add(candidate);
@@ -46547,7 +46563,6 @@ ${lanes.join("\n")}
46547
46563
  var potentialReflectCollisions = [];
46548
46564
  var potentialUnusedRenamedBindingElementsInTypes = [];
46549
46565
  var awaitedTypeStack = [];
46550
- var ambiguousVariableDeclarationsWhenWidened = [];
46551
46566
  var diagnostics = createDiagnosticCollection();
46552
46567
  var suggestionDiagnostics = createDiagnosticCollection();
46553
46568
  var typeofType = createTypeofType();
@@ -54073,7 +54088,7 @@ ${lanes.join("\n")}
54073
54088
  return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
54074
54089
  }
54075
54090
  function getTypeForBindingElement(declaration) {
54076
- const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
54091
+ const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
54077
54092
  const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
54078
54093
  return parentType && getBindingElementTypeFromParentType(
54079
54094
  declaration,
@@ -66240,7 +66255,7 @@ ${lanes.join("\n")}
66240
66255
  if (!couldContainTypeVariables(target)) {
66241
66256
  return;
66242
66257
  }
66243
- if (source === wildcardType) {
66258
+ if (source === wildcardType || source === blockedStringType) {
66244
66259
  const savePropagationType = propagationType;
66245
66260
  propagationType = source;
66246
66261
  inferFromTypes(target, target);
@@ -66297,6 +66312,10 @@ ${lanes.join("\n")}
66297
66312
  return;
66298
66313
  }
66299
66314
  if (!inference.isFixed) {
66315
+ const candidate = propagationType || source;
66316
+ if (candidate === blockedStringType) {
66317
+ return;
66318
+ }
66300
66319
  if (inference.priority === void 0 || priority < inference.priority) {
66301
66320
  inference.candidates = void 0;
66302
66321
  inference.contraCandidates = void 0;
@@ -66304,7 +66323,6 @@ ${lanes.join("\n")}
66304
66323
  inference.priority = priority;
66305
66324
  }
66306
66325
  if (priority === inference.priority) {
66307
- const candidate = propagationType || source;
66308
66326
  if (contravariant && !bivariant) {
66309
66327
  if (!contains(inference.contraCandidates, candidate)) {
66310
66328
  inference.contraCandidates = append(inference.contraCandidates, candidate);
@@ -66876,7 +66894,7 @@ ${lanes.join("\n")}
66876
66894
  const constraint = getConstraintOfTypeParameter(inference.typeParameter);
66877
66895
  if (constraint) {
66878
66896
  const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
66879
- if (!inferredType || inferredType === blockedStringType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
66897
+ if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
66880
66898
  inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
66881
66899
  }
66882
66900
  }
@@ -67727,7 +67745,10 @@ ${lanes.join("\n")}
67727
67745
  let signature = links.effectsSignature;
67728
67746
  if (signature === void 0) {
67729
67747
  let funcType;
67730
- 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 */) {
67731
67752
  funcType = getTypeOfDottedName(
67732
67753
  node.expression,
67733
67754
  /*diagnostic*/
@@ -68751,7 +68772,22 @@ ${lanes.join("\n")}
68751
68772
  }
68752
68773
  return type;
68753
68774
  }
68754
- 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
+ }
68755
68791
  if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
68756
68792
  return type;
68757
68793
  }
@@ -69003,7 +69039,7 @@ ${lanes.join("\n")}
69003
69039
  return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
69004
69040
  }
69005
69041
  function hasContextualTypeWithNoGenericTypes(node, checkMode) {
69006
- 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(
69007
69043
  node,
69008
69044
  /*contextFlags*/
69009
69045
  void 0
@@ -69763,7 +69799,7 @@ ${lanes.join("\n")}
69763
69799
  function getContextualTypeForBindingElement(declaration, contextFlags) {
69764
69800
  const parent2 = declaration.parent.parent;
69765
69801
  const name = declaration.propertyName || declaration.name;
69766
- 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 */);
69767
69803
  if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
69768
69804
  return void 0;
69769
69805
  if (parent2.name.kind === 207 /* ArrayBindingPattern */) {
@@ -72609,7 +72645,9 @@ ${lanes.join("\n")}
72609
72645
  checkExpression(node.template);
72610
72646
  } else if (isJsxOpeningLikeElement(node)) {
72611
72647
  checkExpression(node.attributes);
72612
- } else if (node.kind !== 170 /* Decorator */) {
72648
+ } else if (isBinaryExpression(node)) {
72649
+ checkExpression(node.left);
72650
+ } else if (isCallOrNewExpression(node)) {
72613
72651
  forEach(node.arguments, (argument) => {
72614
72652
  checkExpression(argument);
72615
72653
  });
@@ -72682,6 +72720,8 @@ ${lanes.join("\n")}
72682
72720
  }
72683
72721
  } else if (node.kind === 170 /* Decorator */) {
72684
72722
  argCount = getDecoratorArgumentCount(node, signature);
72723
+ } else if (node.kind === 226 /* BinaryExpression */) {
72724
+ argCount = 1;
72685
72725
  } else if (isJsxOpeningLikeElement(node)) {
72686
72726
  callIsIncomplete = node.attributes.end === node.end;
72687
72727
  if (callIsIncomplete) {
@@ -72781,13 +72821,13 @@ ${lanes.join("\n")}
72781
72821
  return voidType;
72782
72822
  }
72783
72823
  const thisArgumentType = checkExpression(thisArgumentNode);
72784
- 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;
72785
72825
  }
72786
72826
  function inferTypeArguments(node, signature, args, checkMode, context) {
72787
72827
  if (isJsxOpeningLikeElement(node)) {
72788
72828
  return inferJsxTypeArguments(node, signature, checkMode, context);
72789
72829
  }
72790
- if (node.kind !== 170 /* Decorator */) {
72830
+ if (node.kind !== 170 /* Decorator */ && node.kind !== 226 /* BinaryExpression */) {
72791
72831
  const skipBindingPatterns = every(signature.typeParameters, (p) => !!getDefaultFromTypeParameter(p));
72792
72832
  const contextualType = getContextualType2(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
72793
72833
  if (contextualType) {
@@ -72824,7 +72864,7 @@ ${lanes.join("\n")}
72824
72864
  }
72825
72865
  for (let i = 0; i < argCount; i++) {
72826
72866
  const arg = args[i];
72827
- if (arg.kind !== 232 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
72867
+ if (arg.kind !== 232 /* OmittedExpression */) {
72828
72868
  const paramType = getTypeAtPosition(signature, i);
72829
72869
  if (couldContainTypeVariables(paramType)) {
72830
72870
  const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -73116,6 +73156,9 @@ ${lanes.join("\n")}
73116
73156
  }
73117
73157
  }
73118
73158
  function getThisArgumentOfCall(node) {
73159
+ if (node.kind === 226 /* BinaryExpression */) {
73160
+ return node.right;
73161
+ }
73119
73162
  const expression = node.kind === 213 /* CallExpression */ ? node.expression : node.kind === 215 /* TaggedTemplateExpression */ ? node.tag : node.kind === 170 /* Decorator */ && !legacyDecorators ? node.expression : void 0;
73120
73163
  if (expression) {
73121
73164
  const callee = skipOuterExpressions(expression);
@@ -73144,6 +73187,9 @@ ${lanes.join("\n")}
73144
73187
  if (node.kind === 170 /* Decorator */) {
73145
73188
  return getEffectiveDecoratorArguments(node);
73146
73189
  }
73190
+ if (node.kind === 226 /* BinaryExpression */) {
73191
+ return [node.left];
73192
+ }
73147
73193
  if (isJsxOpeningLikeElement(node)) {
73148
73194
  return node.attributes.properties.length > 0 || isJsxOpeningElement(node) && node.parent.children.length > 0 ? [node.attributes] : emptyArray;
73149
73195
  }
@@ -73413,9 +73459,10 @@ ${lanes.join("\n")}
73413
73459
  const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
73414
73460
  const isDecorator2 = node.kind === 170 /* Decorator */;
73415
73461
  const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
73462
+ const isInstanceof = node.kind === 226 /* BinaryExpression */;
73416
73463
  const reportErrors2 = !isInferencePartiallyBlocked && !candidatesOutArray;
73417
73464
  let typeArguments;
73418
- if (!isDecorator2 && !isSuperCall(node)) {
73465
+ if (!isDecorator2 && !isInstanceof && !isSuperCall(node)) {
73419
73466
  typeArguments = node.typeArguments;
73420
73467
  if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 108 /* SuperKeyword */) {
73421
73468
  forEach(typeArguments, checkSourceElement);
@@ -73427,7 +73474,6 @@ ${lanes.join("\n")}
73427
73474
  const args = getEffectiveCallArguments(node);
73428
73475
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
73429
73476
  let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
73430
- argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
73431
73477
  let candidatesForArgumentError;
73432
73478
  let candidateForArgumentArityError;
73433
73479
  let candidateForTypeArgumentError;
@@ -73445,6 +73491,9 @@ ${lanes.join("\n")}
73445
73491
  result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
73446
73492
  getNodeLinks(node).resolvedSignature = result;
73447
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
+ }
73448
73497
  if (candidatesForArgumentError) {
73449
73498
  if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
73450
73499
  const last2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
@@ -74231,6 +74280,30 @@ ${lanes.join("\n")}
74231
74280
  }
74232
74281
  return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
74233
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
+ }
74234
74307
  function isPotentiallyUncalledDecorator(decorator, signatures) {
74235
74308
  return signatures.length && every(signatures, (signature) => signature.minArgumentCount === 0 && !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature));
74236
74309
  }
@@ -74247,6 +74320,8 @@ ${lanes.join("\n")}
74247
74320
  case 286 /* JsxOpeningElement */:
74248
74321
  case 285 /* JsxSelfClosingElement */:
74249
74322
  return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
74323
+ case 226 /* BinaryExpression */:
74324
+ return resolveInstanceofExpression(node, candidatesOutArray, checkMode);
74250
74325
  }
74251
74326
  Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
74252
74327
  }
@@ -76205,16 +76280,35 @@ ${lanes.join("\n")}
76205
76280
  function isConstEnumSymbol(symbol) {
76206
76281
  return (symbol.flags & 128 /* ConstEnum */) !== 0;
76207
76282
  }
76208
- 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) {
76209
76294
  if (leftType === silentNeverType || rightType === silentNeverType) {
76210
76295
  return silentNeverType;
76211
76296
  }
76212
76297
  if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
76213
76298
  error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
76214
76299
  }
76215
- if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
76216
- 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;
76217
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);
76218
76312
  return booleanType;
76219
76313
  }
76220
76314
  function hasEmptyObjectIntersection(type) {
@@ -76752,7 +76846,7 @@ ${lanes.join("\n")}
76752
76846
  case 36 /* ExclamationEqualsToken */:
76753
76847
  case 37 /* EqualsEqualsEqualsToken */:
76754
76848
  case 38 /* ExclamationEqualsEqualsToken */:
76755
- if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
76849
+ if (!(checkMode && checkMode & 64 /* TypeOnly */)) {
76756
76850
  if ((isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) && // only report for === and !== in JS, not == or !=
76757
76851
  (!isInJSFile(left) || (operator === 37 /* EqualsEqualsEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */))) {
76758
76852
  const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
@@ -76763,7 +76857,7 @@ ${lanes.join("\n")}
76763
76857
  }
76764
76858
  return booleanType;
76765
76859
  case 104 /* InstanceOfKeyword */:
76766
- return checkInstanceOfExpression(left, right, leftType, rightType);
76860
+ return checkInstanceOfExpression(left, right, leftType, rightType, checkMode);
76767
76861
  case 103 /* InKeyword */:
76768
76862
  return checkInExpression(left, right, leftType, rightType);
76769
76863
  case 56 /* AmpersandAmpersandToken */:
@@ -77400,7 +77494,7 @@ ${lanes.join("\n")}
77400
77494
  }
77401
77495
  }
77402
77496
  const startInvocationCount = flowInvocationCount;
77403
- const type = checkExpression(node, 128 /* TypeOnly */);
77497
+ const type = checkExpression(node, 64 /* TypeOnly */);
77404
77498
  if (flowInvocationCount !== startInvocationCount) {
77405
77499
  const cache = flowTypeCache || (flowTypeCache = []);
77406
77500
  cache[getNodeId(node)] = type;
@@ -79866,7 +79960,7 @@ ${lanes.join("\n")}
79866
79960
  checkComputedPropertyName(node.propertyName);
79867
79961
  }
79868
79962
  const parent2 = node.parent.parent;
79869
- const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
79963
+ const parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
79870
79964
  const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
79871
79965
  const name = node.propertyName || node.name;
79872
79966
  if (parentType && !isBindingPattern(name)) {
@@ -80007,29 +80101,6 @@ ${lanes.join("\n")}
80007
80101
  }
80008
80102
  checkCollisionsForDeclarationName(node, node.name);
80009
80103
  }
80010
- function canHaveLiteralInitializer2(node2) {
80011
- switch (node2.kind) {
80012
- case 172 /* PropertyDeclaration */:
80013
- case 171 /* PropertySignature */:
80014
- return !hasEffectiveModifier(node2, 8 /* Private */);
80015
- case 169 /* Parameter */:
80016
- case 260 /* VariableDeclaration */:
80017
- return true;
80018
- }
80019
- return false;
80020
- }
80021
- function shouldPrintWithInitializer(node2) {
80022
- return canHaveLiteralInitializer2(node2) && isLiteralConstDeclaration(node2);
80023
- }
80024
- function isPrivateDeclaration(node2) {
80025
- return hasEffectiveModifier(node2, 8 /* Private */) || isPrivateIdentifierClassElementDeclaration(node2);
80026
- }
80027
- if (getEmitDeclarations(compilerOptions) && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) && !shouldPrintWithInitializer(node) && !isPrivateDeclaration(node)) {
80028
- const widenedLiteralType = getWidenedLiteralType(type);
80029
- if (!isTypeIdenticalTo(type, widenedLiteralType)) {
80030
- ambiguousVariableDeclarationsWhenWidened.push([node, type, widenedLiteralType]);
80031
- }
80032
- }
80033
80104
  }
80034
80105
  function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
80035
80106
  const nextDeclarationName = getNameOfDeclaration(nextDeclaration);
@@ -83198,6 +83269,12 @@ ${lanes.join("\n")}
83198
83269
  case 234 /* AsExpression */:
83199
83270
  case 217 /* ParenthesizedExpression */:
83200
83271
  checkAssertionDeferred(node);
83272
+ break;
83273
+ case 226 /* BinaryExpression */:
83274
+ if (isInstanceOfExpression(node)) {
83275
+ resolveUntypedCall(node);
83276
+ }
83277
+ break;
83201
83278
  }
83202
83279
  currentNode = saveCurrentNode;
83203
83280
  (_b = tracing) == null ? void 0 : _b.pop();
@@ -83245,7 +83322,6 @@ ${lanes.join("\n")}
83245
83322
  clear(potentialWeakMapSetCollisions);
83246
83323
  clear(potentialReflectCollisions);
83247
83324
  clear(potentialUnusedRenamedBindingElementsInTypes);
83248
- clear(ambiguousVariableDeclarationsWhenWidened);
83249
83325
  forEach(node.statements, checkSourceElement);
83250
83326
  checkSourceElement(node.endOfFileToken);
83251
83327
  checkDeferredNodes(node);
@@ -83264,23 +83340,6 @@ ${lanes.join("\n")}
83264
83340
  checkPotentialUncheckedRenamedBindingElementsInTypes();
83265
83341
  }
83266
83342
  });
83267
- addLazyDiagnostic(() => {
83268
- function isVisibleExternally(elem) {
83269
- if (isOmittedExpression(elem)) {
83270
- return false;
83271
- }
83272
- if (isBindingPattern(elem.name)) {
83273
- return some(elem.name.elements, isVisibleExternally);
83274
- } else {
83275
- return isDeclarationVisible(elem);
83276
- }
83277
- }
83278
- for (const [node2, type, widenedLiteralType] of ambiguousVariableDeclarationsWhenWidened) {
83279
- if (isVisibleExternally(node2)) {
83280
- error2(node2.name, Diagnostics.The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1, typeToString(widenedLiteralType), typeToString(type));
83281
- }
83282
- }
83283
- });
83284
83343
  if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !node.isDeclarationFile && isExternalModule(node)) {
83285
83344
  checkImportsForTypeOnlyConversion(node);
83286
83345
  }
@@ -83303,9 +83362,6 @@ ${lanes.join("\n")}
83303
83362
  forEach(potentialReflectCollisions, checkReflectCollision);
83304
83363
  clear(potentialReflectCollisions);
83305
83364
  }
83306
- if (ambiguousVariableDeclarationsWhenWidened.length) {
83307
- clear(ambiguousVariableDeclarationsWhenWidened);
83308
- }
83309
83365
  links.flags |= 1 /* TypeChecked */;
83310
83366
  }
83311
83367
  }
@@ -83835,6 +83891,13 @@ ${lanes.join("\n")}
83835
83891
  case 102 /* ImportKeyword */:
83836
83892
  case 105 /* NewKeyword */:
83837
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;
83838
83901
  case 236 /* MetaProperty */:
83839
83902
  return checkExpression(node).symbol;
83840
83903
  case 295 /* JsxNamespacedName */:
@@ -86732,9 +86795,8 @@ ${lanes.join("\n")}
86732
86795
  CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
86733
86796
  CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
86734
86797
  CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
86735
- CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
86736
- CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
86737
- CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
86798
+ CheckMode3[CheckMode3["RestBindingElement"] = 32] = "RestBindingElement";
86799
+ CheckMode3[CheckMode3["TypeOnly"] = 64] = "TypeOnly";
86738
86800
  return CheckMode3;
86739
86801
  })(CheckMode || {});
86740
86802
  SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
@@ -128870,10 +128932,10 @@ ${lanes.join("\n")}
128870
128932
  return LanguageServiceMode2;
128871
128933
  })(LanguageServiceMode || {});
128872
128934
  emptyOptions = {};
128873
- SemanticClassificationFormat = /* @__PURE__ */ ((SemanticClassificationFormat3) => {
128874
- SemanticClassificationFormat3["Original"] = "original";
128875
- SemanticClassificationFormat3["TwentyTwenty"] = "2020";
128876
- return SemanticClassificationFormat3;
128935
+ SemanticClassificationFormat = /* @__PURE__ */ ((SemanticClassificationFormat2) => {
128936
+ SemanticClassificationFormat2["Original"] = "original";
128937
+ SemanticClassificationFormat2["TwentyTwenty"] = "2020";
128938
+ return SemanticClassificationFormat2;
128877
128939
  })(SemanticClassificationFormat || {});
128878
128940
  OrganizeImportsMode = /* @__PURE__ */ ((OrganizeImportsMode3) => {
128879
128941
  OrganizeImportsMode3["All"] = "All";
@@ -128964,15 +129026,15 @@ ${lanes.join("\n")}
128964
129026
  OutputFileType2[OutputFileType2["Declaration"] = 2] = "Declaration";
128965
129027
  return OutputFileType2;
128966
129028
  })(OutputFileType || {});
128967
- EndOfLineState = /* @__PURE__ */ ((EndOfLineState3) => {
128968
- EndOfLineState3[EndOfLineState3["None"] = 0] = "None";
128969
- EndOfLineState3[EndOfLineState3["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia";
128970
- EndOfLineState3[EndOfLineState3["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral";
128971
- EndOfLineState3[EndOfLineState3["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral";
128972
- EndOfLineState3[EndOfLineState3["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate";
128973
- EndOfLineState3[EndOfLineState3["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail";
128974
- EndOfLineState3[EndOfLineState3["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition";
128975
- 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;
128976
129038
  })(EndOfLineState || {});
128977
129039
  TokenClass = /* @__PURE__ */ ((TokenClass2) => {
128978
129040
  TokenClass2[TokenClass2["Punctuation"] = 0] = "Punctuation";
@@ -144104,933 +144166,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
144104
144166
  }
144105
144167
  });
144106
144168
 
144107
- // src/services/shims.ts
144108
- function logInternalError(logger, err) {
144109
- if (logger) {
144110
- logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message);
144111
- }
144112
- }
144113
- function simpleForwardCall(logger, actionDescription2, action, logPerformance) {
144114
- let start;
144115
- if (logPerformance) {
144116
- logger.log(actionDescription2);
144117
- start = timestamp();
144118
- }
144119
- const result = action();
144120
- if (logPerformance) {
144121
- const end = timestamp();
144122
- logger.log(`${actionDescription2} completed in ${end - start} msec`);
144123
- if (isString(result)) {
144124
- let str = result;
144125
- if (str.length > 128) {
144126
- str = str.substring(0, 128) + "...";
144127
- }
144128
- logger.log(` result.length=${str.length}, result='${JSON.stringify(str)}'`);
144129
- }
144130
- }
144131
- return result;
144132
- }
144133
- function forwardJSONCall(logger, actionDescription2, action, logPerformance) {
144134
- return forwardCall(
144135
- logger,
144136
- actionDescription2,
144137
- /*returnJson*/
144138
- true,
144139
- action,
144140
- logPerformance
144141
- );
144142
- }
144143
- function forwardCall(logger, actionDescription2, returnJson, action, logPerformance) {
144144
- try {
144145
- const result = simpleForwardCall(logger, actionDescription2, action, logPerformance);
144146
- return returnJson ? JSON.stringify({ result }) : result;
144147
- } catch (err) {
144148
- if (err instanceof OperationCanceledException) {
144149
- return JSON.stringify({ canceled: true });
144150
- }
144151
- logInternalError(logger, err);
144152
- err.description = actionDescription2;
144153
- return JSON.stringify({ error: err });
144154
- }
144155
- }
144156
- function realizeDiagnostics(diagnostics, newLine) {
144157
- return diagnostics.map((d) => realizeDiagnostic(d, newLine));
144158
- }
144159
- function realizeDiagnostic(diagnostic, newLine) {
144160
- return {
144161
- message: flattenDiagnosticMessageText(diagnostic.messageText, newLine),
144162
- start: diagnostic.start,
144163
- // TODO: GH#18217
144164
- length: diagnostic.length,
144165
- // TODO: GH#18217
144166
- category: diagnosticCategoryName(diagnostic),
144167
- code: diagnostic.code,
144168
- reportsUnnecessary: diagnostic.reportsUnnecessary,
144169
- reportsDeprecated: diagnostic.reportsDeprecated
144170
- };
144171
- }
144172
- function convertClassifications(classifications) {
144173
- return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState };
144174
- }
144175
- var debugObjectHost, ScriptSnapshotShimAdapter, LanguageServiceShimHostAdapter, CoreServicesShimHostAdapter, ShimBase, LanguageServiceShimObject, ClassifierShimObject, CoreServicesShimObject, TypeScriptServicesFactory;
144176
- var init_shims = __esm({
144177
- "src/services/shims.ts"() {
144178
- "use strict";
144179
- init_ts4();
144180
- debugObjectHost = function() {
144181
- return this;
144182
- }();
144183
- ScriptSnapshotShimAdapter = class {
144184
- constructor(scriptSnapshotShim) {
144185
- this.scriptSnapshotShim = scriptSnapshotShim;
144186
- }
144187
- getText(start, end) {
144188
- return this.scriptSnapshotShim.getText(start, end);
144189
- }
144190
- getLength() {
144191
- return this.scriptSnapshotShim.getLength();
144192
- }
144193
- getChangeRange(oldSnapshot) {
144194
- const oldSnapshotShim = oldSnapshot;
144195
- const encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim);
144196
- if (encoded === null) {
144197
- return null;
144198
- }
144199
- const decoded = JSON.parse(encoded);
144200
- return createTextChangeRange(
144201
- createTextSpan(decoded.span.start, decoded.span.length),
144202
- decoded.newLength
144203
- );
144204
- }
144205
- dispose() {
144206
- if ("dispose" in this.scriptSnapshotShim) {
144207
- this.scriptSnapshotShim.dispose();
144208
- }
144209
- }
144210
- };
144211
- LanguageServiceShimHostAdapter = class {
144212
- constructor(shimHost) {
144213
- this.shimHost = shimHost;
144214
- this.loggingEnabled = false;
144215
- this.tracingEnabled = false;
144216
- if ("getModuleResolutionsForFile" in this.shimHost) {
144217
- this.resolveModuleNames = (moduleNames, containingFile) => {
144218
- const resolutionsInFile = JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile));
144219
- return map(moduleNames, (name) => {
144220
- const result = getProperty(resolutionsInFile, name);
144221
- return result ? { resolvedFileName: result, extension: extensionFromPath(result), isExternalLibraryImport: false } : void 0;
144222
- });
144223
- };
144224
- }
144225
- if ("directoryExists" in this.shimHost) {
144226
- this.directoryExists = (directoryName) => this.shimHost.directoryExists(directoryName);
144227
- }
144228
- if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) {
144229
- this.resolveTypeReferenceDirectives = (typeDirectiveNames, containingFile) => {
144230
- const typeDirectivesForFile = JSON.parse(this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile));
144231
- return map(typeDirectiveNames, (name) => getProperty(typeDirectivesForFile, isString(name) ? name : toFileNameLowerCase(name.fileName)));
144232
- };
144233
- }
144234
- if ("jsDocParsingMode" in this.shimHost) {
144235
- this.jsDocParsingMode = this.shimHost.jsDocParsingMode;
144236
- }
144237
- }
144238
- log(s) {
144239
- if (this.loggingEnabled) {
144240
- this.shimHost.log(s);
144241
- }
144242
- }
144243
- trace(s) {
144244
- if (this.tracingEnabled) {
144245
- this.shimHost.trace(s);
144246
- }
144247
- }
144248
- error(s) {
144249
- this.shimHost.error(s);
144250
- }
144251
- getProjectVersion() {
144252
- if (!this.shimHost.getProjectVersion) {
144253
- return void 0;
144254
- }
144255
- return this.shimHost.getProjectVersion();
144256
- }
144257
- getTypeRootsVersion() {
144258
- if (!this.shimHost.getTypeRootsVersion) {
144259
- return 0;
144260
- }
144261
- return this.shimHost.getTypeRootsVersion();
144262
- }
144263
- useCaseSensitiveFileNames() {
144264
- return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
144265
- }
144266
- getCompilationSettings() {
144267
- const settingsJson = this.shimHost.getCompilationSettings();
144268
- if (settingsJson === null || settingsJson === "") {
144269
- throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
144270
- }
144271
- const compilerOptions = JSON.parse(settingsJson);
144272
- compilerOptions.allowNonTsExtensions = true;
144273
- return compilerOptions;
144274
- }
144275
- getScriptFileNames() {
144276
- const encoded = this.shimHost.getScriptFileNames();
144277
- return JSON.parse(encoded);
144278
- }
144279
- getScriptSnapshot(fileName) {
144280
- const scriptSnapshot = this.shimHost.getScriptSnapshot(fileName);
144281
- return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot);
144282
- }
144283
- getScriptKind(fileName) {
144284
- if ("getScriptKind" in this.shimHost) {
144285
- return this.shimHost.getScriptKind(fileName);
144286
- } else {
144287
- return 0 /* Unknown */;
144288
- }
144289
- }
144290
- getScriptVersion(fileName) {
144291
- return this.shimHost.getScriptVersion(fileName);
144292
- }
144293
- getLocalizedDiagnosticMessages() {
144294
- const diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages();
144295
- if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") {
144296
- return null;
144297
- }
144298
- try {
144299
- return JSON.parse(diagnosticMessagesJson);
144300
- } catch (e) {
144301
- this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format");
144302
- return null;
144303
- }
144304
- }
144305
- getCancellationToken() {
144306
- const hostCancellationToken = this.shimHost.getCancellationToken();
144307
- return new ThrottledCancellationToken(hostCancellationToken);
144308
- }
144309
- getCurrentDirectory() {
144310
- return this.shimHost.getCurrentDirectory();
144311
- }
144312
- getDirectories(path) {
144313
- return JSON.parse(this.shimHost.getDirectories(path));
144314
- }
144315
- getDefaultLibFileName(options) {
144316
- return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
144317
- }
144318
- readDirectory(path, extensions, exclude, include, depth) {
144319
- const pattern = getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory());
144320
- return JSON.parse(this.shimHost.readDirectory(
144321
- path,
144322
- JSON.stringify(extensions),
144323
- JSON.stringify(pattern.basePaths),
144324
- pattern.excludePattern,
144325
- pattern.includeFilePattern,
144326
- pattern.includeDirectoryPattern,
144327
- depth
144328
- ));
144329
- }
144330
- readFile(path, encoding) {
144331
- return this.shimHost.readFile(path, encoding);
144332
- }
144333
- fileExists(path) {
144334
- return this.shimHost.fileExists(path);
144335
- }
144336
- };
144337
- CoreServicesShimHostAdapter = class {
144338
- constructor(shimHost) {
144339
- this.shimHost = shimHost;
144340
- this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
144341
- if ("directoryExists" in this.shimHost) {
144342
- this.directoryExists = (directoryName) => this.shimHost.directoryExists(directoryName);
144343
- } else {
144344
- this.directoryExists = void 0;
144345
- }
144346
- if ("realpath" in this.shimHost) {
144347
- this.realpath = (path) => this.shimHost.realpath(path);
144348
- } else {
144349
- this.realpath = void 0;
144350
- }
144351
- }
144352
- readDirectory(rootDir, extensions, exclude, include, depth) {
144353
- const pattern = getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory());
144354
- return JSON.parse(this.shimHost.readDirectory(
144355
- rootDir,
144356
- JSON.stringify(extensions),
144357
- JSON.stringify(pattern.basePaths),
144358
- pattern.excludePattern,
144359
- pattern.includeFilePattern,
144360
- pattern.includeDirectoryPattern,
144361
- depth
144362
- ));
144363
- }
144364
- fileExists(fileName) {
144365
- return this.shimHost.fileExists(fileName);
144366
- }
144367
- readFile(fileName) {
144368
- return this.shimHost.readFile(fileName);
144369
- }
144370
- getDirectories(path) {
144371
- return JSON.parse(this.shimHost.getDirectories(path));
144372
- }
144373
- };
144374
- ShimBase = class {
144375
- constructor(factory2) {
144376
- this.factory = factory2;
144377
- factory2.registerShim(this);
144378
- }
144379
- dispose(_dummy) {
144380
- this.factory.unregisterShim(this);
144381
- }
144382
- };
144383
- LanguageServiceShimObject = class extends ShimBase {
144384
- constructor(factory2, host, languageService) {
144385
- super(factory2);
144386
- this.host = host;
144387
- this.languageService = languageService;
144388
- this.logPerformance = false;
144389
- this.logger = this.host;
144390
- }
144391
- forwardJSONCall(actionDescription2, action) {
144392
- return forwardJSONCall(this.logger, actionDescription2, action, this.logPerformance);
144393
- }
144394
- /// DISPOSE
144395
- /**
144396
- * Ensure (almost) deterministic release of internal Javascript resources when
144397
- * some external native objects holds onto us (e.g. Com/Interop).
144398
- */
144399
- dispose(dummy) {
144400
- this.logger.log("dispose()");
144401
- this.languageService.dispose();
144402
- this.languageService = null;
144403
- if (debugObjectHost && debugObjectHost.CollectGarbage) {
144404
- debugObjectHost.CollectGarbage();
144405
- this.logger.log("CollectGarbage()");
144406
- }
144407
- this.logger = null;
144408
- super.dispose(dummy);
144409
- }
144410
- /// REFRESH
144411
- /**
144412
- * Update the list of scripts known to the compiler
144413
- */
144414
- refresh(throwOnError) {
144415
- this.forwardJSONCall(
144416
- `refresh(${throwOnError})`,
144417
- () => null
144418
- // eslint-disable-line no-null/no-null
144419
- );
144420
- }
144421
- cleanupSemanticCache() {
144422
- this.forwardJSONCall(
144423
- "cleanupSemanticCache()",
144424
- () => {
144425
- this.languageService.cleanupSemanticCache();
144426
- return null;
144427
- }
144428
- );
144429
- }
144430
- realizeDiagnostics(diagnostics) {
144431
- const newLine = getNewLineOrDefaultFromHost(
144432
- this.host,
144433
- /*formatSettings*/
144434
- void 0
144435
- );
144436
- return realizeDiagnostics(diagnostics, newLine);
144437
- }
144438
- getSyntacticClassifications(fileName, start, length2) {
144439
- return this.forwardJSONCall(
144440
- `getSyntacticClassifications('${fileName}', ${start}, ${length2})`,
144441
- () => this.languageService.getSyntacticClassifications(fileName, createTextSpan(start, length2))
144442
- );
144443
- }
144444
- getSemanticClassifications(fileName, start, length2) {
144445
- return this.forwardJSONCall(
144446
- `getSemanticClassifications('${fileName}', ${start}, ${length2})`,
144447
- () => this.languageService.getSemanticClassifications(fileName, createTextSpan(start, length2))
144448
- );
144449
- }
144450
- getEncodedSyntacticClassifications(fileName, start, length2) {
144451
- return this.forwardJSONCall(
144452
- `getEncodedSyntacticClassifications('${fileName}', ${start}, ${length2})`,
144453
- // directly serialize the spans out to a string. This is much faster to decode
144454
- // on the managed side versus a full JSON array.
144455
- () => convertClassifications(this.languageService.getEncodedSyntacticClassifications(fileName, createTextSpan(start, length2)))
144456
- );
144457
- }
144458
- getEncodedSemanticClassifications(fileName, start, length2) {
144459
- return this.forwardJSONCall(
144460
- `getEncodedSemanticClassifications('${fileName}', ${start}, ${length2})`,
144461
- // directly serialize the spans out to a string. This is much faster to decode
144462
- // on the managed side versus a full JSON array.
144463
- () => convertClassifications(this.languageService.getEncodedSemanticClassifications(fileName, createTextSpan(start, length2)))
144464
- );
144465
- }
144466
- getSyntacticDiagnostics(fileName) {
144467
- return this.forwardJSONCall(
144468
- `getSyntacticDiagnostics('${fileName}')`,
144469
- () => {
144470
- const diagnostics = this.languageService.getSyntacticDiagnostics(fileName);
144471
- return this.realizeDiagnostics(diagnostics);
144472
- }
144473
- );
144474
- }
144475
- getSemanticDiagnostics(fileName) {
144476
- return this.forwardJSONCall(
144477
- `getSemanticDiagnostics('${fileName}')`,
144478
- () => {
144479
- const diagnostics = this.languageService.getSemanticDiagnostics(fileName);
144480
- return this.realizeDiagnostics(diagnostics);
144481
- }
144482
- );
144483
- }
144484
- getSuggestionDiagnostics(fileName) {
144485
- return this.forwardJSONCall(`getSuggestionDiagnostics('${fileName}')`, () => this.realizeDiagnostics(this.languageService.getSuggestionDiagnostics(fileName)));
144486
- }
144487
- getCompilerOptionsDiagnostics() {
144488
- return this.forwardJSONCall(
144489
- "getCompilerOptionsDiagnostics()",
144490
- () => {
144491
- const diagnostics = this.languageService.getCompilerOptionsDiagnostics();
144492
- return this.realizeDiagnostics(diagnostics);
144493
- }
144494
- );
144495
- }
144496
- /// QUICKINFO
144497
- /**
144498
- * Computes a string representation of the type at the requested position
144499
- * in the active file.
144500
- */
144501
- getQuickInfoAtPosition(fileName, position) {
144502
- return this.forwardJSONCall(
144503
- `getQuickInfoAtPosition('${fileName}', ${position})`,
144504
- () => this.languageService.getQuickInfoAtPosition(fileName, position)
144505
- );
144506
- }
144507
- /// NAMEORDOTTEDNAMESPAN
144508
- /**
144509
- * Computes span information of the name or dotted name at the requested position
144510
- * in the active file.
144511
- */
144512
- getNameOrDottedNameSpan(fileName, startPos, endPos) {
144513
- return this.forwardJSONCall(
144514
- `getNameOrDottedNameSpan('${fileName}', ${startPos}, ${endPos})`,
144515
- () => this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos)
144516
- );
144517
- }
144518
- /**
144519
- * STATEMENTSPAN
144520
- * Computes span information of statement at the requested position in the active file.
144521
- */
144522
- getBreakpointStatementAtPosition(fileName, position) {
144523
- return this.forwardJSONCall(
144524
- `getBreakpointStatementAtPosition('${fileName}', ${position})`,
144525
- () => this.languageService.getBreakpointStatementAtPosition(fileName, position)
144526
- );
144527
- }
144528
- /// SIGNATUREHELP
144529
- getSignatureHelpItems(fileName, position, options) {
144530
- return this.forwardJSONCall(
144531
- `getSignatureHelpItems('${fileName}', ${position})`,
144532
- () => this.languageService.getSignatureHelpItems(fileName, position, options)
144533
- );
144534
- }
144535
- /// GOTO DEFINITION
144536
- /**
144537
- * Computes the definition location and file for the symbol
144538
- * at the requested position.
144539
- */
144540
- getDefinitionAtPosition(fileName, position) {
144541
- return this.forwardJSONCall(
144542
- `getDefinitionAtPosition('${fileName}', ${position})`,
144543
- () => this.languageService.getDefinitionAtPosition(fileName, position)
144544
- );
144545
- }
144546
- /**
144547
- * Computes the definition location and file for the symbol
144548
- * at the requested position.
144549
- */
144550
- getDefinitionAndBoundSpan(fileName, position) {
144551
- return this.forwardJSONCall(
144552
- `getDefinitionAndBoundSpan('${fileName}', ${position})`,
144553
- () => this.languageService.getDefinitionAndBoundSpan(fileName, position)
144554
- );
144555
- }
144556
- /// GOTO Type
144557
- /**
144558
- * Computes the definition location of the type of the symbol
144559
- * at the requested position.
144560
- */
144561
- getTypeDefinitionAtPosition(fileName, position) {
144562
- return this.forwardJSONCall(
144563
- `getTypeDefinitionAtPosition('${fileName}', ${position})`,
144564
- () => this.languageService.getTypeDefinitionAtPosition(fileName, position)
144565
- );
144566
- }
144567
- /// GOTO Implementation
144568
- /**
144569
- * Computes the implementation location of the symbol
144570
- * at the requested position.
144571
- */
144572
- getImplementationAtPosition(fileName, position) {
144573
- return this.forwardJSONCall(
144574
- `getImplementationAtPosition('${fileName}', ${position})`,
144575
- () => this.languageService.getImplementationAtPosition(fileName, position)
144576
- );
144577
- }
144578
- getRenameInfo(fileName, position, preferences) {
144579
- return this.forwardJSONCall(
144580
- `getRenameInfo('${fileName}', ${position})`,
144581
- () => this.languageService.getRenameInfo(fileName, position, preferences)
144582
- );
144583
- }
144584
- getSmartSelectionRange(fileName, position) {
144585
- return this.forwardJSONCall(
144586
- `getSmartSelectionRange('${fileName}', ${position})`,
144587
- () => this.languageService.getSmartSelectionRange(fileName, position)
144588
- );
144589
- }
144590
- findRenameLocations(fileName, position, findInStrings, findInComments, preferences) {
144591
- return this.forwardJSONCall(
144592
- `findRenameLocations('${fileName}', ${position}, ${findInStrings}, ${findInComments})`,
144593
- () => this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, preferences)
144594
- );
144595
- }
144596
- /// GET BRACE MATCHING
144597
- getBraceMatchingAtPosition(fileName, position) {
144598
- return this.forwardJSONCall(
144599
- `getBraceMatchingAtPosition('${fileName}', ${position})`,
144600
- () => this.languageService.getBraceMatchingAtPosition(fileName, position)
144601
- );
144602
- }
144603
- isValidBraceCompletionAtPosition(fileName, position, openingBrace) {
144604
- return this.forwardJSONCall(
144605
- `isValidBraceCompletionAtPosition('${fileName}', ${position}, ${openingBrace})`,
144606
- () => this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace)
144607
- );
144608
- }
144609
- getSpanOfEnclosingComment(fileName, position, onlyMultiLine) {
144610
- return this.forwardJSONCall(
144611
- `getSpanOfEnclosingComment('${fileName}', ${position})`,
144612
- () => this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine)
144613
- );
144614
- }
144615
- /// GET SMART INDENT
144616
- getIndentationAtPosition(fileName, position, options) {
144617
- return this.forwardJSONCall(
144618
- `getIndentationAtPosition('${fileName}', ${position})`,
144619
- () => {
144620
- const localOptions = JSON.parse(options);
144621
- return this.languageService.getIndentationAtPosition(fileName, position, localOptions);
144622
- }
144623
- );
144624
- }
144625
- /// GET REFERENCES
144626
- getReferencesAtPosition(fileName, position) {
144627
- return this.forwardJSONCall(
144628
- `getReferencesAtPosition('${fileName}', ${position})`,
144629
- () => this.languageService.getReferencesAtPosition(fileName, position)
144630
- );
144631
- }
144632
- findReferences(fileName, position) {
144633
- return this.forwardJSONCall(
144634
- `findReferences('${fileName}', ${position})`,
144635
- () => this.languageService.findReferences(fileName, position)
144636
- );
144637
- }
144638
- getFileReferences(fileName) {
144639
- return this.forwardJSONCall(
144640
- `getFileReferences('${fileName})`,
144641
- () => this.languageService.getFileReferences(fileName)
144642
- );
144643
- }
144644
- getDocumentHighlights(fileName, position, filesToSearch) {
144645
- return this.forwardJSONCall(
144646
- `getDocumentHighlights('${fileName}', ${position})`,
144647
- () => {
144648
- const results = this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch));
144649
- const normalizedName = toFileNameLowerCase(normalizeSlashes(fileName));
144650
- return filter(results, (r) => toFileNameLowerCase(normalizeSlashes(r.fileName)) === normalizedName);
144651
- }
144652
- );
144653
- }
144654
- /// COMPLETION LISTS
144655
- /**
144656
- * Get a string based representation of the completions
144657
- * to provide at the given source position and providing a member completion
144658
- * list if requested.
144659
- */
144660
- getCompletionsAtPosition(fileName, position, preferences, formattingSettings) {
144661
- return this.forwardJSONCall(
144662
- `getCompletionsAtPosition('${fileName}', ${position}, ${preferences}, ${formattingSettings})`,
144663
- () => this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings)
144664
- );
144665
- }
144666
- /** Get a string based representation of a completion list entry details */
144667
- getCompletionEntryDetails(fileName, position, entryName, formatOptions, source, preferences, data) {
144668
- return this.forwardJSONCall(
144669
- `getCompletionEntryDetails('${fileName}', ${position}, '${entryName}')`,
144670
- () => {
144671
- const localOptions = formatOptions === void 0 ? void 0 : JSON.parse(formatOptions);
144672
- return this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data);
144673
- }
144674
- );
144675
- }
144676
- getFormattingEditsForRange(fileName, start, end, options) {
144677
- return this.forwardJSONCall(
144678
- `getFormattingEditsForRange('${fileName}', ${start}, ${end})`,
144679
- () => {
144680
- const localOptions = JSON.parse(options);
144681
- return this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions);
144682
- }
144683
- );
144684
- }
144685
- getFormattingEditsForDocument(fileName, options) {
144686
- return this.forwardJSONCall(
144687
- `getFormattingEditsForDocument('${fileName}')`,
144688
- () => {
144689
- const localOptions = JSON.parse(options);
144690
- return this.languageService.getFormattingEditsForDocument(fileName, localOptions);
144691
- }
144692
- );
144693
- }
144694
- getFormattingEditsAfterKeystroke(fileName, position, key, options) {
144695
- return this.forwardJSONCall(
144696
- `getFormattingEditsAfterKeystroke('${fileName}', ${position}, '${key}')`,
144697
- () => {
144698
- const localOptions = JSON.parse(options);
144699
- return this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions);
144700
- }
144701
- );
144702
- }
144703
- getDocCommentTemplateAtPosition(fileName, position, options, formatOptions) {
144704
- return this.forwardJSONCall(
144705
- `getDocCommentTemplateAtPosition('${fileName}', ${position})`,
144706
- () => this.languageService.getDocCommentTemplateAtPosition(fileName, position, options, formatOptions)
144707
- );
144708
- }
144709
- /// NAVIGATE TO
144710
- /** Return a list of symbols that are interesting to navigate to */
144711
- getNavigateToItems(searchValue, maxResultCount, fileName) {
144712
- return this.forwardJSONCall(
144713
- `getNavigateToItems('${searchValue}', ${maxResultCount}, ${fileName})`,
144714
- () => this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName)
144715
- );
144716
- }
144717
- getNavigationBarItems(fileName) {
144718
- return this.forwardJSONCall(
144719
- `getNavigationBarItems('${fileName}')`,
144720
- () => this.languageService.getNavigationBarItems(fileName)
144721
- );
144722
- }
144723
- getNavigationTree(fileName) {
144724
- return this.forwardJSONCall(
144725
- `getNavigationTree('${fileName}')`,
144726
- () => this.languageService.getNavigationTree(fileName)
144727
- );
144728
- }
144729
- getOutliningSpans(fileName) {
144730
- return this.forwardJSONCall(
144731
- `getOutliningSpans('${fileName}')`,
144732
- () => this.languageService.getOutliningSpans(fileName)
144733
- );
144734
- }
144735
- getTodoComments(fileName, descriptors) {
144736
- return this.forwardJSONCall(
144737
- `getTodoComments('${fileName}')`,
144738
- () => this.languageService.getTodoComments(fileName, JSON.parse(descriptors))
144739
- );
144740
- }
144741
- /// CALL HIERARCHY
144742
- prepareCallHierarchy(fileName, position) {
144743
- return this.forwardJSONCall(
144744
- `prepareCallHierarchy('${fileName}', ${position})`,
144745
- () => this.languageService.prepareCallHierarchy(fileName, position)
144746
- );
144747
- }
144748
- provideCallHierarchyIncomingCalls(fileName, position) {
144749
- return this.forwardJSONCall(
144750
- `provideCallHierarchyIncomingCalls('${fileName}', ${position})`,
144751
- () => this.languageService.provideCallHierarchyIncomingCalls(fileName, position)
144752
- );
144753
- }
144754
- provideCallHierarchyOutgoingCalls(fileName, position) {
144755
- return this.forwardJSONCall(
144756
- `provideCallHierarchyOutgoingCalls('${fileName}', ${position})`,
144757
- () => this.languageService.provideCallHierarchyOutgoingCalls(fileName, position)
144758
- );
144759
- }
144760
- provideInlayHints(fileName, span, preference) {
144761
- return this.forwardJSONCall(
144762
- `provideInlayHints('${fileName}', '${JSON.stringify(span)}', ${JSON.stringify(preference)})`,
144763
- () => this.languageService.provideInlayHints(fileName, span, preference)
144764
- );
144765
- }
144766
- /// Emit
144767
- getEmitOutput(fileName) {
144768
- return this.forwardJSONCall(
144769
- `getEmitOutput('${fileName}')`,
144770
- () => {
144771
- const { diagnostics, ...rest } = this.languageService.getEmitOutput(fileName);
144772
- return { ...rest, diagnostics: this.realizeDiagnostics(diagnostics) };
144773
- }
144774
- );
144775
- }
144776
- getEmitOutputObject(fileName) {
144777
- return forwardCall(
144778
- this.logger,
144779
- `getEmitOutput('${fileName}')`,
144780
- /*returnJson*/
144781
- false,
144782
- () => this.languageService.getEmitOutput(fileName),
144783
- this.logPerformance
144784
- );
144785
- }
144786
- toggleLineComment(fileName, textRange) {
144787
- return this.forwardJSONCall(
144788
- `toggleLineComment('${fileName}', '${JSON.stringify(textRange)}')`,
144789
- () => this.languageService.toggleLineComment(fileName, textRange)
144790
- );
144791
- }
144792
- toggleMultilineComment(fileName, textRange) {
144793
- return this.forwardJSONCall(
144794
- `toggleMultilineComment('${fileName}', '${JSON.stringify(textRange)}')`,
144795
- () => this.languageService.toggleMultilineComment(fileName, textRange)
144796
- );
144797
- }
144798
- commentSelection(fileName, textRange) {
144799
- return this.forwardJSONCall(
144800
- `commentSelection('${fileName}', '${JSON.stringify(textRange)}')`,
144801
- () => this.languageService.commentSelection(fileName, textRange)
144802
- );
144803
- }
144804
- uncommentSelection(fileName, textRange) {
144805
- return this.forwardJSONCall(
144806
- `uncommentSelection('${fileName}', '${JSON.stringify(textRange)}')`,
144807
- () => this.languageService.uncommentSelection(fileName, textRange)
144808
- );
144809
- }
144810
- };
144811
- ClassifierShimObject = class extends ShimBase {
144812
- constructor(factory2, logger) {
144813
- super(factory2);
144814
- this.logger = logger;
144815
- this.logPerformance = false;
144816
- this.classifier = createClassifier();
144817
- }
144818
- getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent = false) {
144819
- return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", () => convertClassifications(this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)), this.logPerformance);
144820
- }
144821
- /// COLORIZATION
144822
- getClassificationsForLine(text, lexState, classifyKeywordsInGenerics = false) {
144823
- const classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics);
144824
- let result = "";
144825
- for (const item of classification.entries) {
144826
- result += item.length + "\n";
144827
- result += item.classification + "\n";
144828
- }
144829
- result += classification.finalLexState;
144830
- return result;
144831
- }
144832
- };
144833
- CoreServicesShimObject = class extends ShimBase {
144834
- constructor(factory2, logger, host) {
144835
- super(factory2);
144836
- this.logger = logger;
144837
- this.host = host;
144838
- this.logPerformance = false;
144839
- }
144840
- forwardJSONCall(actionDescription2, action) {
144841
- return forwardJSONCall(this.logger, actionDescription2, action, this.logPerformance);
144842
- }
144843
- resolveModuleName(fileName, moduleName, compilerOptionsJson) {
144844
- return this.forwardJSONCall(`resolveModuleName('${fileName}')`, () => {
144845
- const compilerOptions = JSON.parse(compilerOptionsJson);
144846
- const result = resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host);
144847
- let resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : void 0;
144848
- if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) {
144849
- resolvedFileName = void 0;
144850
- }
144851
- return {
144852
- resolvedFileName,
144853
- failedLookupLocations: result.failedLookupLocations,
144854
- affectingLocations: result.affectingLocations
144855
- };
144856
- });
144857
- }
144858
- resolveTypeReferenceDirective(fileName, typeReferenceDirective, compilerOptionsJson) {
144859
- return this.forwardJSONCall(`resolveTypeReferenceDirective(${fileName})`, () => {
144860
- const compilerOptions = JSON.parse(compilerOptionsJson);
144861
- const result = resolveTypeReferenceDirective(typeReferenceDirective, normalizeSlashes(fileName), compilerOptions, this.host);
144862
- return {
144863
- resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : void 0,
144864
- primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true,
144865
- failedLookupLocations: result.failedLookupLocations
144866
- };
144867
- });
144868
- }
144869
- getPreProcessedFileInfo(fileName, sourceTextSnapshot) {
144870
- return this.forwardJSONCall(
144871
- `getPreProcessedFileInfo('${fileName}')`,
144872
- () => {
144873
- const result = preProcessFile(
144874
- getSnapshotText(sourceTextSnapshot),
144875
- /*readImportFiles*/
144876
- true,
144877
- /*detectJavaScriptImports*/
144878
- true
144879
- );
144880
- return {
144881
- referencedFiles: this.convertFileReferences(result.referencedFiles),
144882
- importedFiles: this.convertFileReferences(result.importedFiles),
144883
- ambientExternalModules: result.ambientExternalModules,
144884
- isLibFile: result.isLibFile,
144885
- typeReferenceDirectives: this.convertFileReferences(result.typeReferenceDirectives),
144886
- libReferenceDirectives: this.convertFileReferences(result.libReferenceDirectives)
144887
- };
144888
- }
144889
- );
144890
- }
144891
- getAutomaticTypeDirectiveNames(compilerOptionsJson) {
144892
- return this.forwardJSONCall(
144893
- `getAutomaticTypeDirectiveNames('${compilerOptionsJson}')`,
144894
- () => {
144895
- const compilerOptions = JSON.parse(compilerOptionsJson);
144896
- return getAutomaticTypeDirectiveNames(compilerOptions, this.host);
144897
- }
144898
- );
144899
- }
144900
- convertFileReferences(refs) {
144901
- if (!refs) {
144902
- return void 0;
144903
- }
144904
- const result = [];
144905
- for (const ref of refs) {
144906
- result.push({
144907
- path: normalizeSlashes(ref.fileName),
144908
- position: ref.pos,
144909
- length: ref.end - ref.pos
144910
- });
144911
- }
144912
- return result;
144913
- }
144914
- getTSConfigFileInfo(fileName, sourceTextSnapshot) {
144915
- return this.forwardJSONCall(
144916
- `getTSConfigFileInfo('${fileName}')`,
144917
- () => {
144918
- const result = parseJsonText(fileName, getSnapshotText(sourceTextSnapshot));
144919
- const normalizedFileName = normalizeSlashes(fileName);
144920
- const configFile = parseJsonSourceFileConfigFileContent(
144921
- result,
144922
- this.host,
144923
- getDirectoryPath(normalizedFileName),
144924
- /*existingOptions*/
144925
- {},
144926
- normalizedFileName
144927
- );
144928
- return {
144929
- options: configFile.options,
144930
- typeAcquisition: configFile.typeAcquisition,
144931
- files: configFile.fileNames,
144932
- raw: configFile.raw,
144933
- errors: realizeDiagnostics([...result.parseDiagnostics, ...configFile.errors], "\r\n")
144934
- };
144935
- }
144936
- );
144937
- }
144938
- getDefaultCompilationSettings() {
144939
- return this.forwardJSONCall(
144940
- "getDefaultCompilationSettings()",
144941
- () => getDefaultCompilerOptions2()
144942
- );
144943
- }
144944
- discoverTypings(discoverTypingsJson) {
144945
- const getCanonicalFileName = createGetCanonicalFileName(
144946
- /*useCaseSensitiveFileNames*/
144947
- false
144948
- );
144949
- return this.forwardJSONCall("discoverTypings()", () => {
144950
- const info = JSON.parse(discoverTypingsJson);
144951
- if (this.safeList === void 0) {
144952
- this.safeList = ts_JsTyping_exports.loadSafeList(this.host, toPath(info.safeListPath, info.safeListPath, getCanonicalFileName));
144953
- }
144954
- return ts_JsTyping_exports.discoverTypings(
144955
- this.host,
144956
- (msg) => this.logger.log(msg),
144957
- info.fileNames,
144958
- toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName),
144959
- this.safeList,
144960
- info.packageNameToTypingLocation,
144961
- info.typeAcquisition,
144962
- info.unresolvedImports,
144963
- info.typesRegistry,
144964
- emptyOptions
144965
- );
144966
- });
144967
- }
144968
- };
144969
- TypeScriptServicesFactory = class {
144970
- constructor() {
144971
- this._shims = [];
144972
- }
144973
- /*
144974
- * Returns script API version.
144975
- */
144976
- getServicesVersion() {
144977
- return servicesVersion;
144978
- }
144979
- createLanguageServiceShim(host) {
144980
- try {
144981
- if (this.documentRegistry === void 0) {
144982
- this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory());
144983
- }
144984
- const hostAdapter = new LanguageServiceShimHostAdapter(host);
144985
- const languageService = createLanguageService(
144986
- hostAdapter,
144987
- this.documentRegistry,
144988
- /*syntaxOnlyOrLanguageServiceMode*/
144989
- false
144990
- );
144991
- return new LanguageServiceShimObject(this, host, languageService);
144992
- } catch (err) {
144993
- logInternalError(host, err);
144994
- throw err;
144995
- }
144996
- }
144997
- createClassifierShim(logger) {
144998
- try {
144999
- return new ClassifierShimObject(this, logger);
145000
- } catch (err) {
145001
- logInternalError(logger, err);
145002
- throw err;
145003
- }
145004
- }
145005
- createCoreServicesShim(host) {
145006
- try {
145007
- const adapter = new CoreServicesShimHostAdapter(host);
145008
- return new CoreServicesShimObject(this, host, adapter);
145009
- } catch (err) {
145010
- logInternalError(host, err);
145011
- throw err;
145012
- }
145013
- }
145014
- close() {
145015
- clear(this._shims);
145016
- this.documentRegistry = void 0;
145017
- }
145018
- registerShim(shim) {
145019
- this._shims.push(shim);
145020
- }
145021
- unregisterShim(shim) {
145022
- for (let i = 0; i < this._shims.length; i++) {
145023
- if (this._shims[i] === shim) {
145024
- delete this._shims[i];
145025
- return;
145026
- }
145027
- }
145028
- throw new Error("Invalid operation");
145029
- }
145030
- };
145031
- }
145032
- });
145033
-
145034
144169
  // src/services/breakpoints.ts
145035
144170
  function spanInSourceFileAtLocation(sourceFile, position) {
145036
144171
  if (sourceFile.isDeclarationFile) {
@@ -172319,7 +171454,6 @@ ${options.prefix}` : "\n" : options.prefix
172319
171454
  init_transpile();
172320
171455
  init_services();
172321
171456
  init_transform();
172322
- init_shims();
172323
171457
  init_ts_BreakpointResolver();
172324
171458
  init_ts_CallHierarchy();
172325
171459
  init_ts_classifier();
@@ -184095,7 +183229,6 @@ ${e.message}`;
184095
183229
  ConfigFileProgramReloadLevel: () => ConfigFileProgramReloadLevel,
184096
183230
  ContainerFlags: () => ContainerFlags,
184097
183231
  ContextFlags: () => ContextFlags,
184098
- CoreServicesShimHostAdapter: () => CoreServicesShimHostAdapter,
184099
183232
  Debug: () => Debug,
184100
183233
  DiagnosticCategory: () => DiagnosticCategory,
184101
183234
  Diagnostics: () => Diagnostics,
@@ -184144,7 +183277,6 @@ ${e.message}`;
184144
183277
  JsxFlags: () => JsxFlags,
184145
183278
  JsxReferenceKind: () => JsxReferenceKind,
184146
183279
  LanguageServiceMode: () => LanguageServiceMode,
184147
- LanguageServiceShimHostAdapter: () => LanguageServiceShimHostAdapter,
184148
183280
  LanguageVariant: () => LanguageVariant,
184149
183281
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
184150
183282
  ListFormat: () => ListFormat,
@@ -184218,7 +183350,6 @@ ${e.message}`;
184218
183350
  TypeMapKind: () => TypeMapKind,
184219
183351
  TypePredicateKind: () => TypePredicateKind,
184220
183352
  TypeReferenceSerializationKind: () => TypeReferenceSerializationKind,
184221
- TypeScriptServicesFactory: () => TypeScriptServicesFactory,
184222
183353
  UnionReduction: () => UnionReduction,
184223
183354
  UpToDateStatusType: () => UpToDateStatusType,
184224
183355
  VarianceFlags: () => VarianceFlags,
@@ -185481,6 +184612,7 @@ ${e.message}`;
185481
184612
  isInsideJsxElementOrAttribute: () => isInsideJsxElementOrAttribute,
185482
184613
  isInsideNodeModules: () => isInsideNodeModules,
185483
184614
  isInsideTemplateLiteral: () => isInsideTemplateLiteral,
184615
+ isInstanceOfExpression: () => isInstanceOfExpression,
185484
184616
  isInstantiatedModule: () => isInstantiatedModule,
185485
184617
  isInterfaceDeclaration: () => isInterfaceDeclaration,
185486
184618
  isInternalDeclaration: () => isInternalDeclaration,
@@ -185738,6 +184870,7 @@ ${e.message}`;
185738
184870
  isReturnStatement: () => isReturnStatement,
185739
184871
  isReturnStatementWithFixablePromiseHandler: () => isReturnStatementWithFixablePromiseHandler,
185740
184872
  isRightSideOfAccessExpression: () => isRightSideOfAccessExpression,
184873
+ isRightSideOfInstanceofExpression: () => isRightSideOfInstanceofExpression,
185741
184874
  isRightSideOfPropertyAccess: () => isRightSideOfPropertyAccess,
185742
184875
  isRightSideOfQualifiedName: () => isRightSideOfQualifiedName,
185743
184876
  isRightSideOfQualifiedNameOrPropertyAccess: () => isRightSideOfQualifiedNameOrPropertyAccess,
@@ -186062,7 +185195,6 @@ ${e.message}`;
186062
185195
  readJson: () => readJson,
186063
185196
  readJsonConfigFile: () => readJsonConfigFile,
186064
185197
  readJsonOrUndefined: () => readJsonOrUndefined,
186065
- realizeDiagnostics: () => realizeDiagnostics,
186066
185198
  reduceEachLeadingCommentRange: () => reduceEachLeadingCommentRange,
186067
185199
  reduceEachTrailingCommentRange: () => reduceEachTrailingCommentRange,
186068
185200
  reduceLeft: () => reduceLeft,
@@ -186504,7 +185636,6 @@ ${e.message}`;
186504
185636
  ConfigFileProgramReloadLevel: () => ConfigFileProgramReloadLevel,
186505
185637
  ContainerFlags: () => ContainerFlags,
186506
185638
  ContextFlags: () => ContextFlags,
186507
- CoreServicesShimHostAdapter: () => CoreServicesShimHostAdapter,
186508
185639
  Debug: () => Debug,
186509
185640
  DiagnosticCategory: () => DiagnosticCategory,
186510
185641
  Diagnostics: () => Diagnostics,
@@ -186553,7 +185684,6 @@ ${e.message}`;
186553
185684
  JsxFlags: () => JsxFlags,
186554
185685
  JsxReferenceKind: () => JsxReferenceKind,
186555
185686
  LanguageServiceMode: () => LanguageServiceMode,
186556
- LanguageServiceShimHostAdapter: () => LanguageServiceShimHostAdapter,
186557
185687
  LanguageVariant: () => LanguageVariant,
186558
185688
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
186559
185689
  ListFormat: () => ListFormat,
@@ -186627,7 +185757,6 @@ ${e.message}`;
186627
185757
  TypeMapKind: () => TypeMapKind,
186628
185758
  TypePredicateKind: () => TypePredicateKind,
186629
185759
  TypeReferenceSerializationKind: () => TypeReferenceSerializationKind,
186630
- TypeScriptServicesFactory: () => TypeScriptServicesFactory,
186631
185760
  UnionReduction: () => UnionReduction,
186632
185761
  UpToDateStatusType: () => UpToDateStatusType,
186633
185762
  VarianceFlags: () => VarianceFlags,
@@ -187890,6 +187019,7 @@ ${e.message}`;
187890
187019
  isInsideJsxElementOrAttribute: () => isInsideJsxElementOrAttribute,
187891
187020
  isInsideNodeModules: () => isInsideNodeModules,
187892
187021
  isInsideTemplateLiteral: () => isInsideTemplateLiteral,
187022
+ isInstanceOfExpression: () => isInstanceOfExpression,
187893
187023
  isInstantiatedModule: () => isInstantiatedModule,
187894
187024
  isInterfaceDeclaration: () => isInterfaceDeclaration,
187895
187025
  isInternalDeclaration: () => isInternalDeclaration,
@@ -188147,6 +187277,7 @@ ${e.message}`;
188147
187277
  isReturnStatement: () => isReturnStatement,
188148
187278
  isReturnStatementWithFixablePromiseHandler: () => isReturnStatementWithFixablePromiseHandler,
188149
187279
  isRightSideOfAccessExpression: () => isRightSideOfAccessExpression,
187280
+ isRightSideOfInstanceofExpression: () => isRightSideOfInstanceofExpression,
188150
187281
  isRightSideOfPropertyAccess: () => isRightSideOfPropertyAccess,
188151
187282
  isRightSideOfQualifiedName: () => isRightSideOfQualifiedName,
188152
187283
  isRightSideOfQualifiedNameOrPropertyAccess: () => isRightSideOfQualifiedNameOrPropertyAccess,
@@ -188471,7 +187602,6 @@ ${e.message}`;
188471
187602
  readJson: () => readJson,
188472
187603
  readJsonConfigFile: () => readJsonConfigFile,
188473
187604
  readJsonOrUndefined: () => readJsonOrUndefined,
188474
- realizeDiagnostics: () => realizeDiagnostics,
188475
187605
  reduceEachLeadingCommentRange: () => reduceEachLeadingCommentRange,
188476
187606
  reduceEachTrailingCommentRange: () => reduceEachTrailingCommentRange,
188477
187607
  reduceLeft: () => reduceLeft,