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/tsserver.js CHANGED
@@ -61,7 +61,6 @@ __export(server_exports, {
61
61
  ConfigFileProgramReloadLevel: () => ConfigFileProgramReloadLevel,
62
62
  ContainerFlags: () => ContainerFlags,
63
63
  ContextFlags: () => ContextFlags,
64
- CoreServicesShimHostAdapter: () => CoreServicesShimHostAdapter,
65
64
  Debug: () => Debug,
66
65
  DiagnosticCategory: () => DiagnosticCategory,
67
66
  Diagnostics: () => Diagnostics,
@@ -110,7 +109,6 @@ __export(server_exports, {
110
109
  JsxFlags: () => JsxFlags,
111
110
  JsxReferenceKind: () => JsxReferenceKind,
112
111
  LanguageServiceMode: () => LanguageServiceMode,
113
- LanguageServiceShimHostAdapter: () => LanguageServiceShimHostAdapter,
114
112
  LanguageVariant: () => LanguageVariant,
115
113
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
116
114
  ListFormat: () => ListFormat,
@@ -184,7 +182,6 @@ __export(server_exports, {
184
182
  TypeMapKind: () => TypeMapKind,
185
183
  TypePredicateKind: () => TypePredicateKind,
186
184
  TypeReferenceSerializationKind: () => TypeReferenceSerializationKind,
187
- TypeScriptServicesFactory: () => TypeScriptServicesFactory,
188
185
  UnionReduction: () => UnionReduction,
189
186
  UpToDateStatusType: () => UpToDateStatusType,
190
187
  VarianceFlags: () => VarianceFlags,
@@ -1256,7 +1253,7 @@ __export(server_exports, {
1256
1253
  isClassDeclaration: () => isClassDeclaration,
1257
1254
  isClassElement: () => isClassElement,
1258
1255
  isClassExpression: () => isClassExpression,
1259
- isClassFieldAndNotAutoAccessor: () => isClassFieldAndNotAutoAccessor,
1256
+ isClassInstanceProperty: () => isClassInstanceProperty,
1260
1257
  isClassLike: () => isClassLike,
1261
1258
  isClassMemberModifier: () => isClassMemberModifier,
1262
1259
  isClassNamedEvaluationHelperBlock: () => isClassNamedEvaluationHelperBlock,
@@ -1447,6 +1444,7 @@ __export(server_exports, {
1447
1444
  isInsideJsxElementOrAttribute: () => isInsideJsxElementOrAttribute,
1448
1445
  isInsideNodeModules: () => isInsideNodeModules,
1449
1446
  isInsideTemplateLiteral: () => isInsideTemplateLiteral,
1447
+ isInstanceOfExpression: () => isInstanceOfExpression,
1450
1448
  isInstantiatedModule: () => isInstantiatedModule,
1451
1449
  isInterfaceDeclaration: () => isInterfaceDeclaration,
1452
1450
  isInternalDeclaration: () => isInternalDeclaration,
@@ -1704,6 +1702,7 @@ __export(server_exports, {
1704
1702
  isReturnStatement: () => isReturnStatement,
1705
1703
  isReturnStatementWithFixablePromiseHandler: () => isReturnStatementWithFixablePromiseHandler,
1706
1704
  isRightSideOfAccessExpression: () => isRightSideOfAccessExpression,
1705
+ isRightSideOfInstanceofExpression: () => isRightSideOfInstanceofExpression,
1707
1706
  isRightSideOfPropertyAccess: () => isRightSideOfPropertyAccess,
1708
1707
  isRightSideOfQualifiedName: () => isRightSideOfQualifiedName,
1709
1708
  isRightSideOfQualifiedNameOrPropertyAccess: () => isRightSideOfQualifiedNameOrPropertyAccess,
@@ -2028,7 +2027,6 @@ __export(server_exports, {
2028
2027
  readJson: () => readJson,
2029
2028
  readJsonConfigFile: () => readJsonConfigFile,
2030
2029
  readJsonOrUndefined: () => readJsonOrUndefined,
2031
- realizeDiagnostics: () => realizeDiagnostics,
2032
2030
  reduceEachLeadingCommentRange: () => reduceEachLeadingCommentRange,
2033
2031
  reduceEachTrailingCommentRange: () => reduceEachTrailingCommentRange,
2034
2032
  reduceLeft: () => reduceLeft,
@@ -2330,7 +2328,7 @@ module.exports = __toCommonJS(server_exports);
2330
2328
 
2331
2329
  // src/compiler/corePublic.ts
2332
2330
  var versionMajorMinor = "5.3";
2333
- var version = `${versionMajorMinor}.0-dev.20230928`;
2331
+ var version = `${versionMajorMinor}.0-dev.20230930`;
2334
2332
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2335
2333
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2336
2334
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -7427,12 +7425,12 @@ var commentPragmas = {
7427
7425
  kind: 4 /* MultiLine */
7428
7426
  }
7429
7427
  };
7430
- var JSDocParsingMode = /* @__PURE__ */ ((JSDocParsingMode7) => {
7431
- JSDocParsingMode7[JSDocParsingMode7["ParseAll"] = 0] = "ParseAll";
7432
- JSDocParsingMode7[JSDocParsingMode7["ParseNone"] = 1] = "ParseNone";
7433
- JSDocParsingMode7[JSDocParsingMode7["ParseForTypeErrors"] = 2] = "ParseForTypeErrors";
7434
- JSDocParsingMode7[JSDocParsingMode7["ParseForTypeInfo"] = 3] = "ParseForTypeInfo";
7435
- return JSDocParsingMode7;
7428
+ var JSDocParsingMode = /* @__PURE__ */ ((JSDocParsingMode6) => {
7429
+ JSDocParsingMode6[JSDocParsingMode6["ParseAll"] = 0] = "ParseAll";
7430
+ JSDocParsingMode6[JSDocParsingMode6["ParseNone"] = 1] = "ParseNone";
7431
+ JSDocParsingMode6[JSDocParsingMode6["ParseForTypeErrors"] = 2] = "ParseForTypeErrors";
7432
+ JSDocParsingMode6[JSDocParsingMode6["ParseForTypeInfo"] = 3] = "ParseForTypeInfo";
7433
+ return JSDocParsingMode6;
7436
7434
  })(JSDocParsingMode || {});
7437
7435
 
7438
7436
  // src/compiler/sys.ts
@@ -9732,7 +9730,7 @@ var Diagnostics = {
9732
9730
  An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
9733
9731
  The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
9734
9732
  The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
9735
- The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
9733
+ The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_type_assignable_to_the_Function_interface_type_or_an_object_type_with_a_Symbol_hasInstance_method: diag(2359, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_2359", "The right-hand side of an 'instanceof' expression must be either of type 'any', a class, function, or other type assignable to the 'Function' interface type, or an object type with a 'Symbol.hasInstance' method."),
9736
9734
  The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, 1 /* Error */, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
9737
9735
  The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, 1 /* Error */, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
9738
9736
  The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, 1 /* Error */, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."),
@@ -10181,6 +10179,8 @@ var Diagnostics = {
10181
10179
  Import_attributes_cannot_be_used_with_type_only_imports_or_exports: diag(2857, 1 /* Error */, "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857", "Import attributes cannot be used with type-only imports or exports."),
10182
10180
  Import_attribute_values_must_be_string_literal_expressions: diag(2858, 1 /* Error */, "Import_attribute_values_must_be_string_literal_expressions_2858", "Import attribute values must be string literal expressions."),
10183
10181
  Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."),
10182
+ The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method: diag(2860, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2860", "The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method."),
10183
+ An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression: diag(2861, 1 /* Error */, "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2861", "An object's '[Symbol.hasInstance]' method must return a boolean value for it to be used on the right-hand side of an 'instanceof' expression."),
10184
10184
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
10185
10185
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
10186
10186
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -14486,7 +14486,14 @@ function isAccessor(node) {
14486
14486
  function isAutoAccessorPropertyDeclaration(node) {
14487
14487
  return isPropertyDeclaration(node) && hasAccessorModifier(node);
14488
14488
  }
14489
- function isClassFieldAndNotAutoAccessor(node) {
14489
+ function isClassInstanceProperty(node) {
14490
+ if (isInJSFile(node) && isExpandoPropertyDeclaration(node)) {
14491
+ return (!isBindableStaticAccessExpression(node) || !isPrototypeAccess(node.expression)) && !isBindableStaticNameExpression(
14492
+ node,
14493
+ /*excludeThisKeyword*/
14494
+ true
14495
+ );
14496
+ }
14490
14497
  return node.parent && isClassLike(node.parent) && isPropertyDeclaration(node) && !hasAccessorModifier(node);
14491
14498
  }
14492
14499
  function isMethodOrAccessor(node) {
@@ -16919,6 +16926,8 @@ function getInvokedExpression(node) {
16919
16926
  case 286 /* JsxOpeningElement */:
16920
16927
  case 285 /* JsxSelfClosingElement */:
16921
16928
  return node.tagName;
16929
+ case 226 /* BinaryExpression */:
16930
+ return node.right;
16922
16931
  default:
16923
16932
  return node.expression;
16924
16933
  }
@@ -19575,6 +19584,12 @@ function isRightSideOfAccessExpression(node) {
19575
19584
  function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
19576
19585
  return isQualifiedName(node.parent) && node.parent.right === node || isPropertyAccessExpression(node.parent) && node.parent.name === node || isJSDocMemberName(node.parent) && node.parent.right === node;
19577
19586
  }
19587
+ function isInstanceOfExpression(node) {
19588
+ return isBinaryExpression(node) && node.operatorToken.kind === 104 /* InstanceOfKeyword */;
19589
+ }
19590
+ function isRightSideOfInstanceofExpression(node) {
19591
+ return isInstanceOfExpression(node.parent) && node === node.parent.right;
19592
+ }
19578
19593
  function isEmptyObjectLiteral(expression) {
19579
19594
  return expression.kind === 210 /* ObjectLiteralExpression */ && expression.properties.length === 0;
19580
19595
  }
@@ -47783,9 +47798,8 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
47783
47798
  CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
47784
47799
  CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
47785
47800
  CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
47786
- CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
47787
- CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
47788
- CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
47801
+ CheckMode3[CheckMode3["RestBindingElement"] = 32] = "RestBindingElement";
47802
+ CheckMode3[CheckMode3["TypeOnly"] = 64] = "TypeOnly";
47789
47803
  return CheckMode3;
47790
47804
  })(CheckMode || {});
47791
47805
  var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
@@ -48272,7 +48286,7 @@ function createTypeChecker(host) {
48272
48286
  candidates,
48273
48287
  /*argumentCount*/
48274
48288
  void 0,
48275
- 32 /* IsForStringLiteralArgumentCompletions */
48289
+ 0 /* Normal */
48276
48290
  ));
48277
48291
  for (const candidate of candidates) {
48278
48292
  candidatesSet.add(candidate);
@@ -56307,7 +56321,7 @@ function createTypeChecker(host) {
56307
56321
  return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
56308
56322
  }
56309
56323
  function getTypeForBindingElement(declaration) {
56310
- const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
56324
+ const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
56311
56325
  const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
56312
56326
  return parentType && getBindingElementTypeFromParentType(
56313
56327
  declaration,
@@ -68474,7 +68488,7 @@ function createTypeChecker(host) {
68474
68488
  if (!couldContainTypeVariables(target)) {
68475
68489
  return;
68476
68490
  }
68477
- if (source === wildcardType) {
68491
+ if (source === wildcardType || source === blockedStringType) {
68478
68492
  const savePropagationType = propagationType;
68479
68493
  propagationType = source;
68480
68494
  inferFromTypes(target, target);
@@ -68531,6 +68545,10 @@ function createTypeChecker(host) {
68531
68545
  return;
68532
68546
  }
68533
68547
  if (!inference.isFixed) {
68548
+ const candidate = propagationType || source;
68549
+ if (candidate === blockedStringType) {
68550
+ return;
68551
+ }
68534
68552
  if (inference.priority === void 0 || priority < inference.priority) {
68535
68553
  inference.candidates = void 0;
68536
68554
  inference.contraCandidates = void 0;
@@ -68538,7 +68556,6 @@ function createTypeChecker(host) {
68538
68556
  inference.priority = priority;
68539
68557
  }
68540
68558
  if (priority === inference.priority) {
68541
- const candidate = propagationType || source;
68542
68559
  if (contravariant && !bivariant) {
68543
68560
  if (!contains(inference.contraCandidates, candidate)) {
68544
68561
  inference.contraCandidates = append(inference.contraCandidates, candidate);
@@ -69110,7 +69127,7 @@ function createTypeChecker(host) {
69110
69127
  const constraint = getConstraintOfTypeParameter(inference.typeParameter);
69111
69128
  if (constraint) {
69112
69129
  const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
69113
- if (!inferredType || inferredType === blockedStringType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
69130
+ if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
69114
69131
  inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
69115
69132
  }
69116
69133
  }
@@ -69961,7 +69978,10 @@ function createTypeChecker(host) {
69961
69978
  let signature = links.effectsSignature;
69962
69979
  if (signature === void 0) {
69963
69980
  let funcType;
69964
- if (node.parent.kind === 244 /* ExpressionStatement */) {
69981
+ if (isBinaryExpression(node)) {
69982
+ const rightType = checkNonNullExpression(node.right);
69983
+ funcType = getSymbolHasInstanceMethodOfObjectType(rightType);
69984
+ } else if (node.parent.kind === 244 /* ExpressionStatement */) {
69965
69985
  funcType = getTypeOfDottedName(
69966
69986
  node.expression,
69967
69987
  /*diagnostic*/
@@ -70985,7 +71005,22 @@ function createTypeChecker(host) {
70985
71005
  }
70986
71006
  return type;
70987
71007
  }
70988
- const rightType = getTypeOfExpression(expr.right);
71008
+ const right = expr.right;
71009
+ const rightType = getTypeOfExpression(right);
71010
+ if (!isTypeDerivedFrom(rightType, globalObjectType)) {
71011
+ return type;
71012
+ }
71013
+ const signature = getEffectsSignature(expr);
71014
+ const predicate = signature && getTypePredicateOfSignature(signature);
71015
+ if (predicate && predicate.kind === 1 /* Identifier */ && predicate.parameterIndex === 0) {
71016
+ return getNarrowedType(
71017
+ type,
71018
+ predicate.type,
71019
+ assumeTrue,
71020
+ /*checkDerived*/
71021
+ true
71022
+ );
71023
+ }
70989
71024
  if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
70990
71025
  return type;
70991
71026
  }
@@ -71237,7 +71272,7 @@ function createTypeChecker(host) {
71237
71272
  return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
71238
71273
  }
71239
71274
  function hasContextualTypeWithNoGenericTypes(node, checkMode) {
71240
- const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
71275
+ const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 32 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
71241
71276
  node,
71242
71277
  /*contextFlags*/
71243
71278
  void 0
@@ -71997,7 +72032,7 @@ function createTypeChecker(host) {
71997
72032
  function getContextualTypeForBindingElement(declaration, contextFlags) {
71998
72033
  const parent2 = declaration.parent.parent;
71999
72034
  const name = declaration.propertyName || declaration.name;
72000
- const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 208 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
72035
+ const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 208 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
72001
72036
  if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
72002
72037
  return void 0;
72003
72038
  if (parent2.name.kind === 207 /* ArrayBindingPattern */) {
@@ -73980,7 +74015,7 @@ function createTypeChecker(host) {
73980
74015
  }
73981
74016
  return false;
73982
74017
  }
73983
- if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassFieldAndNotAutoAccessor))) {
74018
+ if (!(flags & 32 /* Static */) && ((_a = prop.declarations) == null ? void 0 : _a.some(isClassInstanceProperty))) {
73984
74019
  if (errorNode) {
73985
74020
  error2(errorNode, Diagnostics.Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super, symbolToString(prop));
73986
74021
  }
@@ -74843,7 +74878,9 @@ function createTypeChecker(host) {
74843
74878
  checkExpression(node.template);
74844
74879
  } else if (isJsxOpeningLikeElement(node)) {
74845
74880
  checkExpression(node.attributes);
74846
- } else if (node.kind !== 170 /* Decorator */) {
74881
+ } else if (isBinaryExpression(node)) {
74882
+ checkExpression(node.left);
74883
+ } else if (isCallOrNewExpression(node)) {
74847
74884
  forEach(node.arguments, (argument) => {
74848
74885
  checkExpression(argument);
74849
74886
  });
@@ -74916,6 +74953,8 @@ function createTypeChecker(host) {
74916
74953
  }
74917
74954
  } else if (node.kind === 170 /* Decorator */) {
74918
74955
  argCount = getDecoratorArgumentCount(node, signature);
74956
+ } else if (node.kind === 226 /* BinaryExpression */) {
74957
+ argCount = 1;
74919
74958
  } else if (isJsxOpeningLikeElement(node)) {
74920
74959
  callIsIncomplete = node.attributes.end === node.end;
74921
74960
  if (callIsIncomplete) {
@@ -75015,13 +75054,13 @@ function createTypeChecker(host) {
75015
75054
  return voidType;
75016
75055
  }
75017
75056
  const thisArgumentType = checkExpression(thisArgumentNode);
75018
- return isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : thisArgumentType;
75057
+ return isRightSideOfInstanceofExpression(thisArgumentNode) ? thisArgumentType : isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : thisArgumentType;
75019
75058
  }
75020
75059
  function inferTypeArguments(node, signature, args, checkMode, context) {
75021
75060
  if (isJsxOpeningLikeElement(node)) {
75022
75061
  return inferJsxTypeArguments(node, signature, checkMode, context);
75023
75062
  }
75024
- if (node.kind !== 170 /* Decorator */) {
75063
+ if (node.kind !== 170 /* Decorator */ && node.kind !== 226 /* BinaryExpression */) {
75025
75064
  const skipBindingPatterns = every(signature.typeParameters, (p) => !!getDefaultFromTypeParameter(p));
75026
75065
  const contextualType = getContextualType2(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
75027
75066
  if (contextualType) {
@@ -75058,7 +75097,7 @@ function createTypeChecker(host) {
75058
75097
  }
75059
75098
  for (let i = 0; i < argCount; i++) {
75060
75099
  const arg = args[i];
75061
- if (arg.kind !== 232 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
75100
+ if (arg.kind !== 232 /* OmittedExpression */) {
75062
75101
  const paramType = getTypeAtPosition(signature, i);
75063
75102
  if (couldContainTypeVariables(paramType)) {
75064
75103
  const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -75350,6 +75389,9 @@ function createTypeChecker(host) {
75350
75389
  }
75351
75390
  }
75352
75391
  function getThisArgumentOfCall(node) {
75392
+ if (node.kind === 226 /* BinaryExpression */) {
75393
+ return node.right;
75394
+ }
75353
75395
  const expression = node.kind === 213 /* CallExpression */ ? node.expression : node.kind === 215 /* TaggedTemplateExpression */ ? node.tag : node.kind === 170 /* Decorator */ && !legacyDecorators ? node.expression : void 0;
75354
75396
  if (expression) {
75355
75397
  const callee = skipOuterExpressions(expression);
@@ -75378,6 +75420,9 @@ function createTypeChecker(host) {
75378
75420
  if (node.kind === 170 /* Decorator */) {
75379
75421
  return getEffectiveDecoratorArguments(node);
75380
75422
  }
75423
+ if (node.kind === 226 /* BinaryExpression */) {
75424
+ return [node.left];
75425
+ }
75381
75426
  if (isJsxOpeningLikeElement(node)) {
75382
75427
  return node.attributes.properties.length > 0 || isJsxOpeningElement(node) && node.parent.children.length > 0 ? [node.attributes] : emptyArray;
75383
75428
  }
@@ -75647,9 +75692,10 @@ function createTypeChecker(host) {
75647
75692
  const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
75648
75693
  const isDecorator2 = node.kind === 170 /* Decorator */;
75649
75694
  const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
75695
+ const isInstanceof = node.kind === 226 /* BinaryExpression */;
75650
75696
  const reportErrors2 = !isInferencePartiallyBlocked && !candidatesOutArray;
75651
75697
  let typeArguments;
75652
- if (!isDecorator2 && !isSuperCall(node)) {
75698
+ if (!isDecorator2 && !isInstanceof && !isSuperCall(node)) {
75653
75699
  typeArguments = node.typeArguments;
75654
75700
  if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 108 /* SuperKeyword */) {
75655
75701
  forEach(typeArguments, checkSourceElement);
@@ -75661,7 +75707,6 @@ function createTypeChecker(host) {
75661
75707
  const args = getEffectiveCallArguments(node);
75662
75708
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
75663
75709
  let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
75664
- argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
75665
75710
  let candidatesForArgumentError;
75666
75711
  let candidateForArgumentArityError;
75667
75712
  let candidateForTypeArgumentError;
@@ -75679,6 +75724,9 @@ function createTypeChecker(host) {
75679
75724
  result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
75680
75725
  getNodeLinks(node).resolvedSignature = result;
75681
75726
  if (reportErrors2) {
75727
+ if (!headMessage && isInstanceof) {
75728
+ headMessage = Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method;
75729
+ }
75682
75730
  if (candidatesForArgumentError) {
75683
75731
  if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
75684
75732
  const last2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
@@ -76465,6 +76513,30 @@ function createTypeChecker(host) {
76465
76513
  }
76466
76514
  return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
76467
76515
  }
76516
+ function resolveInstanceofExpression(node, candidatesOutArray, checkMode) {
76517
+ const rightType = checkExpression(node.right);
76518
+ if (!isTypeAny(rightType)) {
76519
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(rightType);
76520
+ if (hasInstanceMethodType) {
76521
+ const apparentType = getApparentType(hasInstanceMethodType);
76522
+ if (isErrorType(apparentType)) {
76523
+ return resolveErrorCall(node);
76524
+ }
76525
+ const callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
76526
+ const constructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */);
76527
+ if (isUntypedFunctionCall(hasInstanceMethodType, apparentType, callSignatures.length, constructSignatures.length)) {
76528
+ return resolveUntypedCall(node);
76529
+ }
76530
+ if (callSignatures.length) {
76531
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
76532
+ }
76533
+ } else if (!(typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
76534
+ error2(node.right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_type_assignable_to_the_Function_interface_type_or_an_object_type_with_a_Symbol_hasInstance_method);
76535
+ return resolveErrorCall(node);
76536
+ }
76537
+ }
76538
+ return anySignature;
76539
+ }
76468
76540
  function isPotentiallyUncalledDecorator(decorator, signatures) {
76469
76541
  return signatures.length && every(signatures, (signature) => signature.minArgumentCount === 0 && !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature));
76470
76542
  }
@@ -76481,6 +76553,8 @@ function createTypeChecker(host) {
76481
76553
  case 286 /* JsxOpeningElement */:
76482
76554
  case 285 /* JsxSelfClosingElement */:
76483
76555
  return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
76556
+ case 226 /* BinaryExpression */:
76557
+ return resolveInstanceofExpression(node, candidatesOutArray, checkMode);
76484
76558
  }
76485
76559
  Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
76486
76560
  }
@@ -78439,16 +78513,35 @@ function createTypeChecker(host) {
78439
78513
  function isConstEnumSymbol(symbol) {
78440
78514
  return (symbol.flags & 128 /* ConstEnum */) !== 0;
78441
78515
  }
78442
- function checkInstanceOfExpression(left, right, leftType, rightType) {
78516
+ function getSymbolHasInstanceMethodOfObjectType(type) {
78517
+ const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
78518
+ const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
78519
+ if (hasInstanceProperty) {
78520
+ const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
78521
+ if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, 0 /* Call */).length !== 0) {
78522
+ return hasInstancePropertyType;
78523
+ }
78524
+ }
78525
+ }
78526
+ function checkInstanceOfExpression(left, right, leftType, rightType, checkMode) {
78443
78527
  if (leftType === silentNeverType || rightType === silentNeverType) {
78444
78528
  return silentNeverType;
78445
78529
  }
78446
78530
  if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
78447
78531
  error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
78448
78532
  }
78449
- if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
78450
- error2(right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
78533
+ Debug.assert(isInstanceOfExpression(left.parent));
78534
+ const signature = getResolvedSignature(
78535
+ left.parent,
78536
+ /*candidatesOutArray*/
78537
+ void 0,
78538
+ checkMode
78539
+ );
78540
+ if (signature === resolvingSignature) {
78541
+ return silentNeverType;
78451
78542
  }
78543
+ const returnType = getReturnTypeOfSignature(signature);
78544
+ checkTypeAssignableTo(returnType, booleanType, right, Diagnostics.An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression);
78452
78545
  return booleanType;
78453
78546
  }
78454
78547
  function hasEmptyObjectIntersection(type) {
@@ -78986,7 +79079,7 @@ function createTypeChecker(host) {
78986
79079
  case 36 /* ExclamationEqualsToken */:
78987
79080
  case 37 /* EqualsEqualsEqualsToken */:
78988
79081
  case 38 /* ExclamationEqualsEqualsToken */:
78989
- if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
79082
+ if (!(checkMode && checkMode & 64 /* TypeOnly */)) {
78990
79083
  if ((isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) && // only report for === and !== in JS, not == or !=
78991
79084
  (!isInJSFile(left) || (operator === 37 /* EqualsEqualsEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */))) {
78992
79085
  const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
@@ -78997,7 +79090,7 @@ function createTypeChecker(host) {
78997
79090
  }
78998
79091
  return booleanType;
78999
79092
  case 104 /* InstanceOfKeyword */:
79000
- return checkInstanceOfExpression(left, right, leftType, rightType);
79093
+ return checkInstanceOfExpression(left, right, leftType, rightType, checkMode);
79001
79094
  case 103 /* InKeyword */:
79002
79095
  return checkInExpression(left, right, leftType, rightType);
79003
79096
  case 56 /* AmpersandAmpersandToken */:
@@ -79634,7 +79727,7 @@ function createTypeChecker(host) {
79634
79727
  }
79635
79728
  }
79636
79729
  const startInvocationCount = flowInvocationCount;
79637
- const type = checkExpression(node, 128 /* TypeOnly */);
79730
+ const type = checkExpression(node, 64 /* TypeOnly */);
79638
79731
  if (flowInvocationCount !== startInvocationCount) {
79639
79732
  const cache = flowTypeCache || (flowTypeCache = []);
79640
79733
  cache[getNodeId(node)] = type;
@@ -82100,7 +82193,7 @@ function createTypeChecker(host) {
82100
82193
  checkComputedPropertyName(node.propertyName);
82101
82194
  }
82102
82195
  const parent2 = node.parent.parent;
82103
- const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
82196
+ const parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
82104
82197
  const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
82105
82198
  const name = node.propertyName || node.name;
82106
82199
  if (parentType && !isBindingPattern(name)) {
@@ -84317,7 +84410,7 @@ function createTypeChecker(host) {
84317
84410
  }
84318
84411
  if (isConstantVariable(symbol)) {
84319
84412
  const declaration = symbol.valueDeclaration;
84320
- if (declaration && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
84413
+ if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
84321
84414
  return evaluate(declaration.initializer, declaration);
84322
84415
  }
84323
84416
  }
@@ -85409,6 +85502,12 @@ function createTypeChecker(host) {
85409
85502
  case 234 /* AsExpression */:
85410
85503
  case 217 /* ParenthesizedExpression */:
85411
85504
  checkAssertionDeferred(node);
85505
+ break;
85506
+ case 226 /* BinaryExpression */:
85507
+ if (isInstanceOfExpression(node)) {
85508
+ resolveUntypedCall(node);
85509
+ }
85510
+ break;
85412
85511
  }
85413
85512
  currentNode = saveCurrentNode;
85414
85513
  (_b = tracing) == null ? void 0 : _b.pop();
@@ -86025,6 +86124,13 @@ function createTypeChecker(host) {
86025
86124
  case 102 /* ImportKeyword */:
86026
86125
  case 105 /* NewKeyword */:
86027
86126
  return isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : void 0;
86127
+ case 104 /* InstanceOfKeyword */:
86128
+ if (isBinaryExpression(node.parent)) {
86129
+ const type = getTypeOfExpression(node.parent.right);
86130
+ const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(type);
86131
+ return (hasInstanceMethodType == null ? void 0 : hasInstanceMethodType.symbol) ?? type.symbol;
86132
+ }
86133
+ return void 0;
86028
86134
  case 236 /* MetaProperty */:
86029
86135
  return checkExpression(node).symbol;
86030
86136
  case 295 /* JsxNamespacedName */:
@@ -130495,10 +130601,10 @@ var LanguageServiceMode = /* @__PURE__ */ ((LanguageServiceMode2) => {
130495
130601
  return LanguageServiceMode2;
130496
130602
  })(LanguageServiceMode || {});
130497
130603
  var emptyOptions = {};
130498
- var SemanticClassificationFormat = /* @__PURE__ */ ((SemanticClassificationFormat3) => {
130499
- SemanticClassificationFormat3["Original"] = "original";
130500
- SemanticClassificationFormat3["TwentyTwenty"] = "2020";
130501
- return SemanticClassificationFormat3;
130604
+ var SemanticClassificationFormat = /* @__PURE__ */ ((SemanticClassificationFormat2) => {
130605
+ SemanticClassificationFormat2["Original"] = "original";
130606
+ SemanticClassificationFormat2["TwentyTwenty"] = "2020";
130607
+ return SemanticClassificationFormat2;
130502
130608
  })(SemanticClassificationFormat || {});
130503
130609
  var OrganizeImportsMode = /* @__PURE__ */ ((OrganizeImportsMode3) => {
130504
130610
  OrganizeImportsMode3["All"] = "All";
@@ -130615,15 +130721,15 @@ var OutputFileType = /* @__PURE__ */ ((OutputFileType2) => {
130615
130721
  OutputFileType2[OutputFileType2["Declaration"] = 2] = "Declaration";
130616
130722
  return OutputFileType2;
130617
130723
  })(OutputFileType || {});
130618
- var EndOfLineState = /* @__PURE__ */ ((EndOfLineState3) => {
130619
- EndOfLineState3[EndOfLineState3["None"] = 0] = "None";
130620
- EndOfLineState3[EndOfLineState3["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia";
130621
- EndOfLineState3[EndOfLineState3["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral";
130622
- EndOfLineState3[EndOfLineState3["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral";
130623
- EndOfLineState3[EndOfLineState3["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate";
130624
- EndOfLineState3[EndOfLineState3["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail";
130625
- EndOfLineState3[EndOfLineState3["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition";
130626
- return EndOfLineState3;
130724
+ var EndOfLineState = /* @__PURE__ */ ((EndOfLineState2) => {
130725
+ EndOfLineState2[EndOfLineState2["None"] = 0] = "None";
130726
+ EndOfLineState2[EndOfLineState2["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia";
130727
+ EndOfLineState2[EndOfLineState2["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral";
130728
+ EndOfLineState2[EndOfLineState2["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral";
130729
+ EndOfLineState2[EndOfLineState2["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate";
130730
+ EndOfLineState2[EndOfLineState2["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail";
130731
+ EndOfLineState2[EndOfLineState2["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition";
130732
+ return EndOfLineState2;
130627
130733
  })(EndOfLineState || {});
130628
130734
  var TokenClass = /* @__PURE__ */ ((TokenClass2) => {
130629
130735
  TokenClass2[TokenClass2["Punctuation"] = 0] = "Punctuation";
@@ -145432,926 +145538,6 @@ function transform(source, transformers, compilerOptions) {
145432
145538
  return result;
145433
145539
  }
145434
145540
 
145435
- // src/services/shims.ts
145436
- var debugObjectHost = function() {
145437
- return this;
145438
- }();
145439
- function logInternalError(logger, err) {
145440
- if (logger) {
145441
- logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message);
145442
- }
145443
- }
145444
- var ScriptSnapshotShimAdapter = class {
145445
- constructor(scriptSnapshotShim) {
145446
- this.scriptSnapshotShim = scriptSnapshotShim;
145447
- }
145448
- getText(start2, end) {
145449
- return this.scriptSnapshotShim.getText(start2, end);
145450
- }
145451
- getLength() {
145452
- return this.scriptSnapshotShim.getLength();
145453
- }
145454
- getChangeRange(oldSnapshot) {
145455
- const oldSnapshotShim = oldSnapshot;
145456
- const encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim);
145457
- if (encoded === null) {
145458
- return null;
145459
- }
145460
- const decoded = JSON.parse(encoded);
145461
- return createTextChangeRange(
145462
- createTextSpan(decoded.span.start, decoded.span.length),
145463
- decoded.newLength
145464
- );
145465
- }
145466
- dispose() {
145467
- if ("dispose" in this.scriptSnapshotShim) {
145468
- this.scriptSnapshotShim.dispose();
145469
- }
145470
- }
145471
- };
145472
- var LanguageServiceShimHostAdapter = class {
145473
- constructor(shimHost) {
145474
- this.shimHost = shimHost;
145475
- this.loggingEnabled = false;
145476
- this.tracingEnabled = false;
145477
- if ("getModuleResolutionsForFile" in this.shimHost) {
145478
- this.resolveModuleNames = (moduleNames, containingFile) => {
145479
- const resolutionsInFile = JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile));
145480
- return map(moduleNames, (name) => {
145481
- const result = getProperty(resolutionsInFile, name);
145482
- return result ? { resolvedFileName: result, extension: extensionFromPath(result), isExternalLibraryImport: false } : void 0;
145483
- });
145484
- };
145485
- }
145486
- if ("directoryExists" in this.shimHost) {
145487
- this.directoryExists = (directoryName) => this.shimHost.directoryExists(directoryName);
145488
- }
145489
- if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) {
145490
- this.resolveTypeReferenceDirectives = (typeDirectiveNames, containingFile) => {
145491
- const typeDirectivesForFile = JSON.parse(this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile));
145492
- return map(typeDirectiveNames, (name) => getProperty(typeDirectivesForFile, isString(name) ? name : toFileNameLowerCase(name.fileName)));
145493
- };
145494
- }
145495
- if ("jsDocParsingMode" in this.shimHost) {
145496
- this.jsDocParsingMode = this.shimHost.jsDocParsingMode;
145497
- }
145498
- }
145499
- log(s) {
145500
- if (this.loggingEnabled) {
145501
- this.shimHost.log(s);
145502
- }
145503
- }
145504
- trace(s) {
145505
- if (this.tracingEnabled) {
145506
- this.shimHost.trace(s);
145507
- }
145508
- }
145509
- error(s) {
145510
- this.shimHost.error(s);
145511
- }
145512
- getProjectVersion() {
145513
- if (!this.shimHost.getProjectVersion) {
145514
- return void 0;
145515
- }
145516
- return this.shimHost.getProjectVersion();
145517
- }
145518
- getTypeRootsVersion() {
145519
- if (!this.shimHost.getTypeRootsVersion) {
145520
- return 0;
145521
- }
145522
- return this.shimHost.getTypeRootsVersion();
145523
- }
145524
- useCaseSensitiveFileNames() {
145525
- return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
145526
- }
145527
- getCompilationSettings() {
145528
- const settingsJson = this.shimHost.getCompilationSettings();
145529
- if (settingsJson === null || settingsJson === "") {
145530
- throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
145531
- }
145532
- const compilerOptions = JSON.parse(settingsJson);
145533
- compilerOptions.allowNonTsExtensions = true;
145534
- return compilerOptions;
145535
- }
145536
- getScriptFileNames() {
145537
- const encoded = this.shimHost.getScriptFileNames();
145538
- return JSON.parse(encoded);
145539
- }
145540
- getScriptSnapshot(fileName) {
145541
- const scriptSnapshot = this.shimHost.getScriptSnapshot(fileName);
145542
- return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot);
145543
- }
145544
- getScriptKind(fileName) {
145545
- if ("getScriptKind" in this.shimHost) {
145546
- return this.shimHost.getScriptKind(fileName);
145547
- } else {
145548
- return 0 /* Unknown */;
145549
- }
145550
- }
145551
- getScriptVersion(fileName) {
145552
- return this.shimHost.getScriptVersion(fileName);
145553
- }
145554
- getLocalizedDiagnosticMessages() {
145555
- const diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages();
145556
- if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") {
145557
- return null;
145558
- }
145559
- try {
145560
- return JSON.parse(diagnosticMessagesJson);
145561
- } catch (e) {
145562
- this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format");
145563
- return null;
145564
- }
145565
- }
145566
- getCancellationToken() {
145567
- const hostCancellationToken = this.shimHost.getCancellationToken();
145568
- return new ThrottledCancellationToken(hostCancellationToken);
145569
- }
145570
- getCurrentDirectory() {
145571
- return this.shimHost.getCurrentDirectory();
145572
- }
145573
- getDirectories(path) {
145574
- return JSON.parse(this.shimHost.getDirectories(path));
145575
- }
145576
- getDefaultLibFileName(options) {
145577
- return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
145578
- }
145579
- readDirectory(path, extensions, exclude, include, depth) {
145580
- const pattern = getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory());
145581
- return JSON.parse(this.shimHost.readDirectory(
145582
- path,
145583
- JSON.stringify(extensions),
145584
- JSON.stringify(pattern.basePaths),
145585
- pattern.excludePattern,
145586
- pattern.includeFilePattern,
145587
- pattern.includeDirectoryPattern,
145588
- depth
145589
- ));
145590
- }
145591
- readFile(path, encoding) {
145592
- return this.shimHost.readFile(path, encoding);
145593
- }
145594
- fileExists(path) {
145595
- return this.shimHost.fileExists(path);
145596
- }
145597
- };
145598
- var CoreServicesShimHostAdapter = class {
145599
- constructor(shimHost) {
145600
- this.shimHost = shimHost;
145601
- this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
145602
- if ("directoryExists" in this.shimHost) {
145603
- this.directoryExists = (directoryName) => this.shimHost.directoryExists(directoryName);
145604
- } else {
145605
- this.directoryExists = void 0;
145606
- }
145607
- if ("realpath" in this.shimHost) {
145608
- this.realpath = (path) => this.shimHost.realpath(path);
145609
- } else {
145610
- this.realpath = void 0;
145611
- }
145612
- }
145613
- readDirectory(rootDir, extensions, exclude, include, depth) {
145614
- const pattern = getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory());
145615
- return JSON.parse(this.shimHost.readDirectory(
145616
- rootDir,
145617
- JSON.stringify(extensions),
145618
- JSON.stringify(pattern.basePaths),
145619
- pattern.excludePattern,
145620
- pattern.includeFilePattern,
145621
- pattern.includeDirectoryPattern,
145622
- depth
145623
- ));
145624
- }
145625
- fileExists(fileName) {
145626
- return this.shimHost.fileExists(fileName);
145627
- }
145628
- readFile(fileName) {
145629
- return this.shimHost.readFile(fileName);
145630
- }
145631
- getDirectories(path) {
145632
- return JSON.parse(this.shimHost.getDirectories(path));
145633
- }
145634
- };
145635
- function simpleForwardCall(logger, actionDescription2, action, logPerformance) {
145636
- let start2;
145637
- if (logPerformance) {
145638
- logger.log(actionDescription2);
145639
- start2 = timestamp();
145640
- }
145641
- const result = action();
145642
- if (logPerformance) {
145643
- const end = timestamp();
145644
- logger.log(`${actionDescription2} completed in ${end - start2} msec`);
145645
- if (isString(result)) {
145646
- let str = result;
145647
- if (str.length > 128) {
145648
- str = str.substring(0, 128) + "...";
145649
- }
145650
- logger.log(` result.length=${str.length}, result='${JSON.stringify(str)}'`);
145651
- }
145652
- }
145653
- return result;
145654
- }
145655
- function forwardJSONCall(logger, actionDescription2, action, logPerformance) {
145656
- return forwardCall(
145657
- logger,
145658
- actionDescription2,
145659
- /*returnJson*/
145660
- true,
145661
- action,
145662
- logPerformance
145663
- );
145664
- }
145665
- function forwardCall(logger, actionDescription2, returnJson, action, logPerformance) {
145666
- try {
145667
- const result = simpleForwardCall(logger, actionDescription2, action, logPerformance);
145668
- return returnJson ? JSON.stringify({ result }) : result;
145669
- } catch (err) {
145670
- if (err instanceof OperationCanceledException) {
145671
- return JSON.stringify({ canceled: true });
145672
- }
145673
- logInternalError(logger, err);
145674
- err.description = actionDescription2;
145675
- return JSON.stringify({ error: err });
145676
- }
145677
- }
145678
- var ShimBase = class {
145679
- constructor(factory2) {
145680
- this.factory = factory2;
145681
- factory2.registerShim(this);
145682
- }
145683
- dispose(_dummy) {
145684
- this.factory.unregisterShim(this);
145685
- }
145686
- };
145687
- function realizeDiagnostics(diagnostics, newLine) {
145688
- return diagnostics.map((d) => realizeDiagnostic(d, newLine));
145689
- }
145690
- function realizeDiagnostic(diagnostic, newLine) {
145691
- return {
145692
- message: flattenDiagnosticMessageText(diagnostic.messageText, newLine),
145693
- start: diagnostic.start,
145694
- // TODO: GH#18217
145695
- length: diagnostic.length,
145696
- // TODO: GH#18217
145697
- category: diagnosticCategoryName(diagnostic),
145698
- code: diagnostic.code,
145699
- reportsUnnecessary: diagnostic.reportsUnnecessary,
145700
- reportsDeprecated: diagnostic.reportsDeprecated
145701
- };
145702
- }
145703
- var LanguageServiceShimObject = class extends ShimBase {
145704
- constructor(factory2, host, languageService) {
145705
- super(factory2);
145706
- this.host = host;
145707
- this.languageService = languageService;
145708
- this.logPerformance = false;
145709
- this.logger = this.host;
145710
- }
145711
- forwardJSONCall(actionDescription2, action) {
145712
- return forwardJSONCall(this.logger, actionDescription2, action, this.logPerformance);
145713
- }
145714
- /// DISPOSE
145715
- /**
145716
- * Ensure (almost) deterministic release of internal Javascript resources when
145717
- * some external native objects holds onto us (e.g. Com/Interop).
145718
- */
145719
- dispose(dummy) {
145720
- this.logger.log("dispose()");
145721
- this.languageService.dispose();
145722
- this.languageService = null;
145723
- if (debugObjectHost && debugObjectHost.CollectGarbage) {
145724
- debugObjectHost.CollectGarbage();
145725
- this.logger.log("CollectGarbage()");
145726
- }
145727
- this.logger = null;
145728
- super.dispose(dummy);
145729
- }
145730
- /// REFRESH
145731
- /**
145732
- * Update the list of scripts known to the compiler
145733
- */
145734
- refresh(throwOnError) {
145735
- this.forwardJSONCall(
145736
- `refresh(${throwOnError})`,
145737
- () => null
145738
- // eslint-disable-line no-null/no-null
145739
- );
145740
- }
145741
- cleanupSemanticCache() {
145742
- this.forwardJSONCall(
145743
- "cleanupSemanticCache()",
145744
- () => {
145745
- this.languageService.cleanupSemanticCache();
145746
- return null;
145747
- }
145748
- );
145749
- }
145750
- realizeDiagnostics(diagnostics) {
145751
- const newLine = getNewLineOrDefaultFromHost(
145752
- this.host,
145753
- /*formatSettings*/
145754
- void 0
145755
- );
145756
- return realizeDiagnostics(diagnostics, newLine);
145757
- }
145758
- getSyntacticClassifications(fileName, start2, length2) {
145759
- return this.forwardJSONCall(
145760
- `getSyntacticClassifications('${fileName}', ${start2}, ${length2})`,
145761
- () => this.languageService.getSyntacticClassifications(fileName, createTextSpan(start2, length2))
145762
- );
145763
- }
145764
- getSemanticClassifications(fileName, start2, length2) {
145765
- return this.forwardJSONCall(
145766
- `getSemanticClassifications('${fileName}', ${start2}, ${length2})`,
145767
- () => this.languageService.getSemanticClassifications(fileName, createTextSpan(start2, length2))
145768
- );
145769
- }
145770
- getEncodedSyntacticClassifications(fileName, start2, length2) {
145771
- return this.forwardJSONCall(
145772
- `getEncodedSyntacticClassifications('${fileName}', ${start2}, ${length2})`,
145773
- // directly serialize the spans out to a string. This is much faster to decode
145774
- // on the managed side versus a full JSON array.
145775
- () => convertClassifications(this.languageService.getEncodedSyntacticClassifications(fileName, createTextSpan(start2, length2)))
145776
- );
145777
- }
145778
- getEncodedSemanticClassifications(fileName, start2, length2) {
145779
- return this.forwardJSONCall(
145780
- `getEncodedSemanticClassifications('${fileName}', ${start2}, ${length2})`,
145781
- // directly serialize the spans out to a string. This is much faster to decode
145782
- // on the managed side versus a full JSON array.
145783
- () => convertClassifications(this.languageService.getEncodedSemanticClassifications(fileName, createTextSpan(start2, length2)))
145784
- );
145785
- }
145786
- getSyntacticDiagnostics(fileName) {
145787
- return this.forwardJSONCall(
145788
- `getSyntacticDiagnostics('${fileName}')`,
145789
- () => {
145790
- const diagnostics = this.languageService.getSyntacticDiagnostics(fileName);
145791
- return this.realizeDiagnostics(diagnostics);
145792
- }
145793
- );
145794
- }
145795
- getSemanticDiagnostics(fileName) {
145796
- return this.forwardJSONCall(
145797
- `getSemanticDiagnostics('${fileName}')`,
145798
- () => {
145799
- const diagnostics = this.languageService.getSemanticDiagnostics(fileName);
145800
- return this.realizeDiagnostics(diagnostics);
145801
- }
145802
- );
145803
- }
145804
- getSuggestionDiagnostics(fileName) {
145805
- return this.forwardJSONCall(`getSuggestionDiagnostics('${fileName}')`, () => this.realizeDiagnostics(this.languageService.getSuggestionDiagnostics(fileName)));
145806
- }
145807
- getCompilerOptionsDiagnostics() {
145808
- return this.forwardJSONCall(
145809
- "getCompilerOptionsDiagnostics()",
145810
- () => {
145811
- const diagnostics = this.languageService.getCompilerOptionsDiagnostics();
145812
- return this.realizeDiagnostics(diagnostics);
145813
- }
145814
- );
145815
- }
145816
- /// QUICKINFO
145817
- /**
145818
- * Computes a string representation of the type at the requested position
145819
- * in the active file.
145820
- */
145821
- getQuickInfoAtPosition(fileName, position) {
145822
- return this.forwardJSONCall(
145823
- `getQuickInfoAtPosition('${fileName}', ${position})`,
145824
- () => this.languageService.getQuickInfoAtPosition(fileName, position)
145825
- );
145826
- }
145827
- /// NAMEORDOTTEDNAMESPAN
145828
- /**
145829
- * Computes span information of the name or dotted name at the requested position
145830
- * in the active file.
145831
- */
145832
- getNameOrDottedNameSpan(fileName, startPos, endPos) {
145833
- return this.forwardJSONCall(
145834
- `getNameOrDottedNameSpan('${fileName}', ${startPos}, ${endPos})`,
145835
- () => this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos)
145836
- );
145837
- }
145838
- /**
145839
- * STATEMENTSPAN
145840
- * Computes span information of statement at the requested position in the active file.
145841
- */
145842
- getBreakpointStatementAtPosition(fileName, position) {
145843
- return this.forwardJSONCall(
145844
- `getBreakpointStatementAtPosition('${fileName}', ${position})`,
145845
- () => this.languageService.getBreakpointStatementAtPosition(fileName, position)
145846
- );
145847
- }
145848
- /// SIGNATUREHELP
145849
- getSignatureHelpItems(fileName, position, options) {
145850
- return this.forwardJSONCall(
145851
- `getSignatureHelpItems('${fileName}', ${position})`,
145852
- () => this.languageService.getSignatureHelpItems(fileName, position, options)
145853
- );
145854
- }
145855
- /// GOTO DEFINITION
145856
- /**
145857
- * Computes the definition location and file for the symbol
145858
- * at the requested position.
145859
- */
145860
- getDefinitionAtPosition(fileName, position) {
145861
- return this.forwardJSONCall(
145862
- `getDefinitionAtPosition('${fileName}', ${position})`,
145863
- () => this.languageService.getDefinitionAtPosition(fileName, position)
145864
- );
145865
- }
145866
- /**
145867
- * Computes the definition location and file for the symbol
145868
- * at the requested position.
145869
- */
145870
- getDefinitionAndBoundSpan(fileName, position) {
145871
- return this.forwardJSONCall(
145872
- `getDefinitionAndBoundSpan('${fileName}', ${position})`,
145873
- () => this.languageService.getDefinitionAndBoundSpan(fileName, position)
145874
- );
145875
- }
145876
- /// GOTO Type
145877
- /**
145878
- * Computes the definition location of the type of the symbol
145879
- * at the requested position.
145880
- */
145881
- getTypeDefinitionAtPosition(fileName, position) {
145882
- return this.forwardJSONCall(
145883
- `getTypeDefinitionAtPosition('${fileName}', ${position})`,
145884
- () => this.languageService.getTypeDefinitionAtPosition(fileName, position)
145885
- );
145886
- }
145887
- /// GOTO Implementation
145888
- /**
145889
- * Computes the implementation location of the symbol
145890
- * at the requested position.
145891
- */
145892
- getImplementationAtPosition(fileName, position) {
145893
- return this.forwardJSONCall(
145894
- `getImplementationAtPosition('${fileName}', ${position})`,
145895
- () => this.languageService.getImplementationAtPosition(fileName, position)
145896
- );
145897
- }
145898
- getRenameInfo(fileName, position, preferences) {
145899
- return this.forwardJSONCall(
145900
- `getRenameInfo('${fileName}', ${position})`,
145901
- () => this.languageService.getRenameInfo(fileName, position, preferences)
145902
- );
145903
- }
145904
- getSmartSelectionRange(fileName, position) {
145905
- return this.forwardJSONCall(
145906
- `getSmartSelectionRange('${fileName}', ${position})`,
145907
- () => this.languageService.getSmartSelectionRange(fileName, position)
145908
- );
145909
- }
145910
- findRenameLocations(fileName, position, findInStrings, findInComments, preferences) {
145911
- return this.forwardJSONCall(
145912
- `findRenameLocations('${fileName}', ${position}, ${findInStrings}, ${findInComments})`,
145913
- () => this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, preferences)
145914
- );
145915
- }
145916
- /// GET BRACE MATCHING
145917
- getBraceMatchingAtPosition(fileName, position) {
145918
- return this.forwardJSONCall(
145919
- `getBraceMatchingAtPosition('${fileName}', ${position})`,
145920
- () => this.languageService.getBraceMatchingAtPosition(fileName, position)
145921
- );
145922
- }
145923
- isValidBraceCompletionAtPosition(fileName, position, openingBrace) {
145924
- return this.forwardJSONCall(
145925
- `isValidBraceCompletionAtPosition('${fileName}', ${position}, ${openingBrace})`,
145926
- () => this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace)
145927
- );
145928
- }
145929
- getSpanOfEnclosingComment(fileName, position, onlyMultiLine) {
145930
- return this.forwardJSONCall(
145931
- `getSpanOfEnclosingComment('${fileName}', ${position})`,
145932
- () => this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine)
145933
- );
145934
- }
145935
- /// GET SMART INDENT
145936
- getIndentationAtPosition(fileName, position, options) {
145937
- return this.forwardJSONCall(
145938
- `getIndentationAtPosition('${fileName}', ${position})`,
145939
- () => {
145940
- const localOptions = JSON.parse(options);
145941
- return this.languageService.getIndentationAtPosition(fileName, position, localOptions);
145942
- }
145943
- );
145944
- }
145945
- /// GET REFERENCES
145946
- getReferencesAtPosition(fileName, position) {
145947
- return this.forwardJSONCall(
145948
- `getReferencesAtPosition('${fileName}', ${position})`,
145949
- () => this.languageService.getReferencesAtPosition(fileName, position)
145950
- );
145951
- }
145952
- findReferences(fileName, position) {
145953
- return this.forwardJSONCall(
145954
- `findReferences('${fileName}', ${position})`,
145955
- () => this.languageService.findReferences(fileName, position)
145956
- );
145957
- }
145958
- getFileReferences(fileName) {
145959
- return this.forwardJSONCall(
145960
- `getFileReferences('${fileName})`,
145961
- () => this.languageService.getFileReferences(fileName)
145962
- );
145963
- }
145964
- getDocumentHighlights(fileName, position, filesToSearch) {
145965
- return this.forwardJSONCall(
145966
- `getDocumentHighlights('${fileName}', ${position})`,
145967
- () => {
145968
- const results = this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch));
145969
- const normalizedName = toFileNameLowerCase(normalizeSlashes(fileName));
145970
- return filter(results, (r) => toFileNameLowerCase(normalizeSlashes(r.fileName)) === normalizedName);
145971
- }
145972
- );
145973
- }
145974
- /// COMPLETION LISTS
145975
- /**
145976
- * Get a string based representation of the completions
145977
- * to provide at the given source position and providing a member completion
145978
- * list if requested.
145979
- */
145980
- getCompletionsAtPosition(fileName, position, preferences, formattingSettings) {
145981
- return this.forwardJSONCall(
145982
- `getCompletionsAtPosition('${fileName}', ${position}, ${preferences}, ${formattingSettings})`,
145983
- () => this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings)
145984
- );
145985
- }
145986
- /** Get a string based representation of a completion list entry details */
145987
- getCompletionEntryDetails(fileName, position, entryName, formatOptions, source, preferences, data) {
145988
- return this.forwardJSONCall(
145989
- `getCompletionEntryDetails('${fileName}', ${position}, '${entryName}')`,
145990
- () => {
145991
- const localOptions = formatOptions === void 0 ? void 0 : JSON.parse(formatOptions);
145992
- return this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data);
145993
- }
145994
- );
145995
- }
145996
- getFormattingEditsForRange(fileName, start2, end, options) {
145997
- return this.forwardJSONCall(
145998
- `getFormattingEditsForRange('${fileName}', ${start2}, ${end})`,
145999
- () => {
146000
- const localOptions = JSON.parse(options);
146001
- return this.languageService.getFormattingEditsForRange(fileName, start2, end, localOptions);
146002
- }
146003
- );
146004
- }
146005
- getFormattingEditsForDocument(fileName, options) {
146006
- return this.forwardJSONCall(
146007
- `getFormattingEditsForDocument('${fileName}')`,
146008
- () => {
146009
- const localOptions = JSON.parse(options);
146010
- return this.languageService.getFormattingEditsForDocument(fileName, localOptions);
146011
- }
146012
- );
146013
- }
146014
- getFormattingEditsAfterKeystroke(fileName, position, key, options) {
146015
- return this.forwardJSONCall(
146016
- `getFormattingEditsAfterKeystroke('${fileName}', ${position}, '${key}')`,
146017
- () => {
146018
- const localOptions = JSON.parse(options);
146019
- return this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions);
146020
- }
146021
- );
146022
- }
146023
- getDocCommentTemplateAtPosition(fileName, position, options, formatOptions) {
146024
- return this.forwardJSONCall(
146025
- `getDocCommentTemplateAtPosition('${fileName}', ${position})`,
146026
- () => this.languageService.getDocCommentTemplateAtPosition(fileName, position, options, formatOptions)
146027
- );
146028
- }
146029
- /// NAVIGATE TO
146030
- /** Return a list of symbols that are interesting to navigate to */
146031
- getNavigateToItems(searchValue, maxResultCount, fileName) {
146032
- return this.forwardJSONCall(
146033
- `getNavigateToItems('${searchValue}', ${maxResultCount}, ${fileName})`,
146034
- () => this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName)
146035
- );
146036
- }
146037
- getNavigationBarItems(fileName) {
146038
- return this.forwardJSONCall(
146039
- `getNavigationBarItems('${fileName}')`,
146040
- () => this.languageService.getNavigationBarItems(fileName)
146041
- );
146042
- }
146043
- getNavigationTree(fileName) {
146044
- return this.forwardJSONCall(
146045
- `getNavigationTree('${fileName}')`,
146046
- () => this.languageService.getNavigationTree(fileName)
146047
- );
146048
- }
146049
- getOutliningSpans(fileName) {
146050
- return this.forwardJSONCall(
146051
- `getOutliningSpans('${fileName}')`,
146052
- () => this.languageService.getOutliningSpans(fileName)
146053
- );
146054
- }
146055
- getTodoComments(fileName, descriptors) {
146056
- return this.forwardJSONCall(
146057
- `getTodoComments('${fileName}')`,
146058
- () => this.languageService.getTodoComments(fileName, JSON.parse(descriptors))
146059
- );
146060
- }
146061
- /// CALL HIERARCHY
146062
- prepareCallHierarchy(fileName, position) {
146063
- return this.forwardJSONCall(
146064
- `prepareCallHierarchy('${fileName}', ${position})`,
146065
- () => this.languageService.prepareCallHierarchy(fileName, position)
146066
- );
146067
- }
146068
- provideCallHierarchyIncomingCalls(fileName, position) {
146069
- return this.forwardJSONCall(
146070
- `provideCallHierarchyIncomingCalls('${fileName}', ${position})`,
146071
- () => this.languageService.provideCallHierarchyIncomingCalls(fileName, position)
146072
- );
146073
- }
146074
- provideCallHierarchyOutgoingCalls(fileName, position) {
146075
- return this.forwardJSONCall(
146076
- `provideCallHierarchyOutgoingCalls('${fileName}', ${position})`,
146077
- () => this.languageService.provideCallHierarchyOutgoingCalls(fileName, position)
146078
- );
146079
- }
146080
- provideInlayHints(fileName, span, preference) {
146081
- return this.forwardJSONCall(
146082
- `provideInlayHints('${fileName}', '${JSON.stringify(span)}', ${JSON.stringify(preference)})`,
146083
- () => this.languageService.provideInlayHints(fileName, span, preference)
146084
- );
146085
- }
146086
- /// Emit
146087
- getEmitOutput(fileName) {
146088
- return this.forwardJSONCall(
146089
- `getEmitOutput('${fileName}')`,
146090
- () => {
146091
- const { diagnostics, ...rest } = this.languageService.getEmitOutput(fileName);
146092
- return { ...rest, diagnostics: this.realizeDiagnostics(diagnostics) };
146093
- }
146094
- );
146095
- }
146096
- getEmitOutputObject(fileName) {
146097
- return forwardCall(
146098
- this.logger,
146099
- `getEmitOutput('${fileName}')`,
146100
- /*returnJson*/
146101
- false,
146102
- () => this.languageService.getEmitOutput(fileName),
146103
- this.logPerformance
146104
- );
146105
- }
146106
- toggleLineComment(fileName, textRange) {
146107
- return this.forwardJSONCall(
146108
- `toggleLineComment('${fileName}', '${JSON.stringify(textRange)}')`,
146109
- () => this.languageService.toggleLineComment(fileName, textRange)
146110
- );
146111
- }
146112
- toggleMultilineComment(fileName, textRange) {
146113
- return this.forwardJSONCall(
146114
- `toggleMultilineComment('${fileName}', '${JSON.stringify(textRange)}')`,
146115
- () => this.languageService.toggleMultilineComment(fileName, textRange)
146116
- );
146117
- }
146118
- commentSelection(fileName, textRange) {
146119
- return this.forwardJSONCall(
146120
- `commentSelection('${fileName}', '${JSON.stringify(textRange)}')`,
146121
- () => this.languageService.commentSelection(fileName, textRange)
146122
- );
146123
- }
146124
- uncommentSelection(fileName, textRange) {
146125
- return this.forwardJSONCall(
146126
- `uncommentSelection('${fileName}', '${JSON.stringify(textRange)}')`,
146127
- () => this.languageService.uncommentSelection(fileName, textRange)
146128
- );
146129
- }
146130
- };
146131
- function convertClassifications(classifications) {
146132
- return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState };
146133
- }
146134
- var ClassifierShimObject = class extends ShimBase {
146135
- constructor(factory2, logger) {
146136
- super(factory2);
146137
- this.logger = logger;
146138
- this.logPerformance = false;
146139
- this.classifier = createClassifier();
146140
- }
146141
- getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent = false) {
146142
- return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", () => convertClassifications(this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)), this.logPerformance);
146143
- }
146144
- /// COLORIZATION
146145
- getClassificationsForLine(text, lexState, classifyKeywordsInGenerics = false) {
146146
- const classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics);
146147
- let result = "";
146148
- for (const item of classification.entries) {
146149
- result += item.length + "\n";
146150
- result += item.classification + "\n";
146151
- }
146152
- result += classification.finalLexState;
146153
- return result;
146154
- }
146155
- };
146156
- var CoreServicesShimObject = class extends ShimBase {
146157
- constructor(factory2, logger, host) {
146158
- super(factory2);
146159
- this.logger = logger;
146160
- this.host = host;
146161
- this.logPerformance = false;
146162
- }
146163
- forwardJSONCall(actionDescription2, action) {
146164
- return forwardJSONCall(this.logger, actionDescription2, action, this.logPerformance);
146165
- }
146166
- resolveModuleName(fileName, moduleName, compilerOptionsJson) {
146167
- return this.forwardJSONCall(`resolveModuleName('${fileName}')`, () => {
146168
- const compilerOptions = JSON.parse(compilerOptionsJson);
146169
- const result = resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host);
146170
- let resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : void 0;
146171
- if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) {
146172
- resolvedFileName = void 0;
146173
- }
146174
- return {
146175
- resolvedFileName,
146176
- failedLookupLocations: result.failedLookupLocations,
146177
- affectingLocations: result.affectingLocations
146178
- };
146179
- });
146180
- }
146181
- resolveTypeReferenceDirective(fileName, typeReferenceDirective, compilerOptionsJson) {
146182
- return this.forwardJSONCall(`resolveTypeReferenceDirective(${fileName})`, () => {
146183
- const compilerOptions = JSON.parse(compilerOptionsJson);
146184
- const result = resolveTypeReferenceDirective(typeReferenceDirective, normalizeSlashes(fileName), compilerOptions, this.host);
146185
- return {
146186
- resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : void 0,
146187
- primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true,
146188
- failedLookupLocations: result.failedLookupLocations
146189
- };
146190
- });
146191
- }
146192
- getPreProcessedFileInfo(fileName, sourceTextSnapshot) {
146193
- return this.forwardJSONCall(
146194
- `getPreProcessedFileInfo('${fileName}')`,
146195
- () => {
146196
- const result = preProcessFile(
146197
- getSnapshotText(sourceTextSnapshot),
146198
- /*readImportFiles*/
146199
- true,
146200
- /*detectJavaScriptImports*/
146201
- true
146202
- );
146203
- return {
146204
- referencedFiles: this.convertFileReferences(result.referencedFiles),
146205
- importedFiles: this.convertFileReferences(result.importedFiles),
146206
- ambientExternalModules: result.ambientExternalModules,
146207
- isLibFile: result.isLibFile,
146208
- typeReferenceDirectives: this.convertFileReferences(result.typeReferenceDirectives),
146209
- libReferenceDirectives: this.convertFileReferences(result.libReferenceDirectives)
146210
- };
146211
- }
146212
- );
146213
- }
146214
- getAutomaticTypeDirectiveNames(compilerOptionsJson) {
146215
- return this.forwardJSONCall(
146216
- `getAutomaticTypeDirectiveNames('${compilerOptionsJson}')`,
146217
- () => {
146218
- const compilerOptions = JSON.parse(compilerOptionsJson);
146219
- return getAutomaticTypeDirectiveNames(compilerOptions, this.host);
146220
- }
146221
- );
146222
- }
146223
- convertFileReferences(refs) {
146224
- if (!refs) {
146225
- return void 0;
146226
- }
146227
- const result = [];
146228
- for (const ref of refs) {
146229
- result.push({
146230
- path: normalizeSlashes(ref.fileName),
146231
- position: ref.pos,
146232
- length: ref.end - ref.pos
146233
- });
146234
- }
146235
- return result;
146236
- }
146237
- getTSConfigFileInfo(fileName, sourceTextSnapshot) {
146238
- return this.forwardJSONCall(
146239
- `getTSConfigFileInfo('${fileName}')`,
146240
- () => {
146241
- const result = parseJsonText(fileName, getSnapshotText(sourceTextSnapshot));
146242
- const normalizedFileName = normalizeSlashes(fileName);
146243
- const configFile = parseJsonSourceFileConfigFileContent(
146244
- result,
146245
- this.host,
146246
- getDirectoryPath(normalizedFileName),
146247
- /*existingOptions*/
146248
- {},
146249
- normalizedFileName
146250
- );
146251
- return {
146252
- options: configFile.options,
146253
- typeAcquisition: configFile.typeAcquisition,
146254
- files: configFile.fileNames,
146255
- raw: configFile.raw,
146256
- errors: realizeDiagnostics([...result.parseDiagnostics, ...configFile.errors], "\r\n")
146257
- };
146258
- }
146259
- );
146260
- }
146261
- getDefaultCompilationSettings() {
146262
- return this.forwardJSONCall(
146263
- "getDefaultCompilationSettings()",
146264
- () => getDefaultCompilerOptions2()
146265
- );
146266
- }
146267
- discoverTypings(discoverTypingsJson) {
146268
- const getCanonicalFileName = createGetCanonicalFileName(
146269
- /*useCaseSensitiveFileNames*/
146270
- false
146271
- );
146272
- return this.forwardJSONCall("discoverTypings()", () => {
146273
- const info = JSON.parse(discoverTypingsJson);
146274
- if (this.safeList === void 0) {
146275
- this.safeList = ts_JsTyping_exports.loadSafeList(this.host, toPath(info.safeListPath, info.safeListPath, getCanonicalFileName));
146276
- }
146277
- return ts_JsTyping_exports.discoverTypings(
146278
- this.host,
146279
- (msg) => this.logger.log(msg),
146280
- info.fileNames,
146281
- toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName),
146282
- this.safeList,
146283
- info.packageNameToTypingLocation,
146284
- info.typeAcquisition,
146285
- info.unresolvedImports,
146286
- info.typesRegistry,
146287
- emptyOptions
146288
- );
146289
- });
146290
- }
146291
- };
146292
- var TypeScriptServicesFactory = class {
146293
- constructor() {
146294
- this._shims = [];
146295
- }
146296
- /*
146297
- * Returns script API version.
146298
- */
146299
- getServicesVersion() {
146300
- return servicesVersion;
146301
- }
146302
- createLanguageServiceShim(host) {
146303
- try {
146304
- if (this.documentRegistry === void 0) {
146305
- this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory());
146306
- }
146307
- const hostAdapter = new LanguageServiceShimHostAdapter(host);
146308
- const languageService = createLanguageService(
146309
- hostAdapter,
146310
- this.documentRegistry,
146311
- /*syntaxOnlyOrLanguageServiceMode*/
146312
- false
146313
- );
146314
- return new LanguageServiceShimObject(this, host, languageService);
146315
- } catch (err) {
146316
- logInternalError(host, err);
146317
- throw err;
146318
- }
146319
- }
146320
- createClassifierShim(logger) {
146321
- try {
146322
- return new ClassifierShimObject(this, logger);
146323
- } catch (err) {
146324
- logInternalError(logger, err);
146325
- throw err;
146326
- }
146327
- }
146328
- createCoreServicesShim(host) {
146329
- try {
146330
- const adapter = new CoreServicesShimHostAdapter(host);
146331
- return new CoreServicesShimObject(this, host, adapter);
146332
- } catch (err) {
146333
- logInternalError(host, err);
146334
- throw err;
146335
- }
146336
- }
146337
- close() {
146338
- clear(this._shims);
146339
- this.documentRegistry = void 0;
146340
- }
146341
- registerShim(shim) {
146342
- this._shims.push(shim);
146343
- }
146344
- unregisterShim(shim) {
146345
- for (let i = 0; i < this._shims.length; i++) {
146346
- if (this._shims[i] === shim) {
146347
- delete this._shims[i];
146348
- return;
146349
- }
146350
- }
146351
- throw new Error("Invalid operation");
146352
- }
146353
- };
146354
-
146355
145541
  // src/services/_namespaces/ts.BreakpointResolver.ts
146356
145542
  var ts_BreakpointResolver_exports = {};
146357
145543
  __export(ts_BreakpointResolver_exports, {
@@ -165201,14 +164387,14 @@ function provideInlayHints(context) {
165201
164387
  if (isModuleReferenceType(declarationType)) {
165202
164388
  return;
165203
164389
  }
165204
- const hints = typeToInlayHintParts(declarationType);
165205
- if (hints) {
165206
- const hintText = typeof hints === "string" ? hints : hints.map((part) => part.text).join("");
164390
+ const hintParts = typeToInlayHintParts(declarationType);
164391
+ if (hintParts) {
164392
+ const hintText = typeof hintParts === "string" ? hintParts : hintParts.map((part) => part.text).join("");
165207
164393
  const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), hintText);
165208
164394
  if (isVariableNameMatchesType) {
165209
164395
  return;
165210
164396
  }
165211
- addTypeHints(hints, decl.name.end);
164397
+ addTypeHints(hintParts, decl.name.end);
165212
164398
  }
165213
164399
  }
165214
164400
  function visitCallOrNewExpression(expr) {
@@ -165316,9 +164502,9 @@ function provideInlayHints(context) {
165316
164502
  if (isModuleReferenceType(returnType)) {
165317
164503
  return;
165318
164504
  }
165319
- const hint = typeToInlayHintParts(returnType);
165320
- if (hint) {
165321
- addTypeHints(hint, getTypeAnnotationPosition(decl));
164505
+ const hintParts = typeToInlayHintParts(returnType);
164506
+ if (hintParts) {
164507
+ addTypeHints(hintParts, getTypeAnnotationPosition(decl));
165322
164508
  }
165323
164509
  }
165324
164510
  function getTypeAnnotationPosition(decl) {
@@ -165342,14 +164528,14 @@ function provideInlayHints(context) {
165342
164528
  if (effectiveTypeAnnotation) {
165343
164529
  continue;
165344
164530
  }
165345
- const typeDisplayString = getParameterDeclarationTypeDisplayString(signature.parameters[i]);
165346
- if (!typeDisplayString) {
164531
+ const typeHints = getParameterDeclarationTypeHints(signature.parameters[i]);
164532
+ if (!typeHints) {
165347
164533
  continue;
165348
164534
  }
165349
- addTypeHints(typeDisplayString, param.questionToken ? param.questionToken.end : param.name.end);
164535
+ addTypeHints(typeHints, param.questionToken ? param.questionToken.end : param.name.end);
165350
164536
  }
165351
164537
  }
165352
- function getParameterDeclarationTypeDisplayString(symbol) {
164538
+ function getParameterDeclarationTypeHints(symbol) {
165353
164539
  const valueDeclaration = symbol.valueDeclaration;
165354
164540
  if (!valueDeclaration || !isParameter(valueDeclaration)) {
165355
164541
  return void 0;
@@ -165358,7 +164544,7 @@ function provideInlayHints(context) {
165358
164544
  if (isModuleReferenceType(signatureParamType)) {
165359
164545
  return void 0;
165360
164546
  }
165361
- return printTypeInSingleLine(signatureParamType);
164547
+ return typeToInlayHintParts(signatureParamType);
165362
164548
  }
165363
164549
  function printTypeInSingleLine(type) {
165364
164550
  const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
@@ -172750,7 +171936,6 @@ __export(ts_exports2, {
172750
171936
  ConfigFileProgramReloadLevel: () => ConfigFileProgramReloadLevel,
172751
171937
  ContainerFlags: () => ContainerFlags,
172752
171938
  ContextFlags: () => ContextFlags,
172753
- CoreServicesShimHostAdapter: () => CoreServicesShimHostAdapter,
172754
171939
  Debug: () => Debug,
172755
171940
  DiagnosticCategory: () => DiagnosticCategory,
172756
171941
  Diagnostics: () => Diagnostics,
@@ -172799,7 +171984,6 @@ __export(ts_exports2, {
172799
171984
  JsxFlags: () => JsxFlags,
172800
171985
  JsxReferenceKind: () => JsxReferenceKind,
172801
171986
  LanguageServiceMode: () => LanguageServiceMode,
172802
- LanguageServiceShimHostAdapter: () => LanguageServiceShimHostAdapter,
172803
171987
  LanguageVariant: () => LanguageVariant,
172804
171988
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
172805
171989
  ListFormat: () => ListFormat,
@@ -172873,7 +172057,6 @@ __export(ts_exports2, {
172873
172057
  TypeMapKind: () => TypeMapKind,
172874
172058
  TypePredicateKind: () => TypePredicateKind,
172875
172059
  TypeReferenceSerializationKind: () => TypeReferenceSerializationKind,
172876
- TypeScriptServicesFactory: () => TypeScriptServicesFactory,
172877
172060
  UnionReduction: () => UnionReduction,
172878
172061
  UpToDateStatusType: () => UpToDateStatusType,
172879
172062
  VarianceFlags: () => VarianceFlags,
@@ -173945,7 +173128,7 @@ __export(ts_exports2, {
173945
173128
  isClassDeclaration: () => isClassDeclaration,
173946
173129
  isClassElement: () => isClassElement,
173947
173130
  isClassExpression: () => isClassExpression,
173948
- isClassFieldAndNotAutoAccessor: () => isClassFieldAndNotAutoAccessor,
173131
+ isClassInstanceProperty: () => isClassInstanceProperty,
173949
173132
  isClassLike: () => isClassLike,
173950
173133
  isClassMemberModifier: () => isClassMemberModifier,
173951
173134
  isClassNamedEvaluationHelperBlock: () => isClassNamedEvaluationHelperBlock,
@@ -174136,6 +173319,7 @@ __export(ts_exports2, {
174136
173319
  isInsideJsxElementOrAttribute: () => isInsideJsxElementOrAttribute,
174137
173320
  isInsideNodeModules: () => isInsideNodeModules,
174138
173321
  isInsideTemplateLiteral: () => isInsideTemplateLiteral,
173322
+ isInstanceOfExpression: () => isInstanceOfExpression,
174139
173323
  isInstantiatedModule: () => isInstantiatedModule,
174140
173324
  isInterfaceDeclaration: () => isInterfaceDeclaration,
174141
173325
  isInternalDeclaration: () => isInternalDeclaration,
@@ -174393,6 +173577,7 @@ __export(ts_exports2, {
174393
173577
  isReturnStatement: () => isReturnStatement,
174394
173578
  isReturnStatementWithFixablePromiseHandler: () => isReturnStatementWithFixablePromiseHandler,
174395
173579
  isRightSideOfAccessExpression: () => isRightSideOfAccessExpression,
173580
+ isRightSideOfInstanceofExpression: () => isRightSideOfInstanceofExpression,
174396
173581
  isRightSideOfPropertyAccess: () => isRightSideOfPropertyAccess,
174397
173582
  isRightSideOfQualifiedName: () => isRightSideOfQualifiedName,
174398
173583
  isRightSideOfQualifiedNameOrPropertyAccess: () => isRightSideOfQualifiedNameOrPropertyAccess,
@@ -174717,7 +173902,6 @@ __export(ts_exports2, {
174717
173902
  readJson: () => readJson,
174718
173903
  readJsonConfigFile: () => readJsonConfigFile,
174719
173904
  readJsonOrUndefined: () => readJsonOrUndefined,
174720
- realizeDiagnostics: () => realizeDiagnostics,
174721
173905
  reduceEachLeadingCommentRange: () => reduceEachLeadingCommentRange,
174722
173906
  reduceEachTrailingCommentRange: () => reduceEachTrailingCommentRange,
174723
173907
  reduceLeft: () => reduceLeft,
@@ -187431,7 +186615,6 @@ start(initializeNodeSystem(), require("os").platform());
187431
186615
  ConfigFileProgramReloadLevel,
187432
186616
  ContainerFlags,
187433
186617
  ContextFlags,
187434
- CoreServicesShimHostAdapter,
187435
186618
  Debug,
187436
186619
  DiagnosticCategory,
187437
186620
  Diagnostics,
@@ -187480,7 +186663,6 @@ start(initializeNodeSystem(), require("os").platform());
187480
186663
  JsxFlags,
187481
186664
  JsxReferenceKind,
187482
186665
  LanguageServiceMode,
187483
- LanguageServiceShimHostAdapter,
187484
186666
  LanguageVariant,
187485
186667
  LexicalEnvironmentFlags,
187486
186668
  ListFormat,
@@ -187554,7 +186736,6 @@ start(initializeNodeSystem(), require("os").platform());
187554
186736
  TypeMapKind,
187555
186737
  TypePredicateKind,
187556
186738
  TypeReferenceSerializationKind,
187557
- TypeScriptServicesFactory,
187558
186739
  UnionReduction,
187559
186740
  UpToDateStatusType,
187560
186741
  VarianceFlags,
@@ -188626,7 +187807,7 @@ start(initializeNodeSystem(), require("os").platform());
188626
187807
  isClassDeclaration,
188627
187808
  isClassElement,
188628
187809
  isClassExpression,
188629
- isClassFieldAndNotAutoAccessor,
187810
+ isClassInstanceProperty,
188630
187811
  isClassLike,
188631
187812
  isClassMemberModifier,
188632
187813
  isClassNamedEvaluationHelperBlock,
@@ -188817,6 +187998,7 @@ start(initializeNodeSystem(), require("os").platform());
188817
187998
  isInsideJsxElementOrAttribute,
188818
187999
  isInsideNodeModules,
188819
188000
  isInsideTemplateLiteral,
188001
+ isInstanceOfExpression,
188820
188002
  isInstantiatedModule,
188821
188003
  isInterfaceDeclaration,
188822
188004
  isInternalDeclaration,
@@ -189074,6 +188256,7 @@ start(initializeNodeSystem(), require("os").platform());
189074
188256
  isReturnStatement,
189075
188257
  isReturnStatementWithFixablePromiseHandler,
189076
188258
  isRightSideOfAccessExpression,
188259
+ isRightSideOfInstanceofExpression,
189077
188260
  isRightSideOfPropertyAccess,
189078
188261
  isRightSideOfQualifiedName,
189079
188262
  isRightSideOfQualifiedNameOrPropertyAccess,
@@ -189398,7 +188581,6 @@ start(initializeNodeSystem(), require("os").platform());
189398
188581
  readJson,
189399
188582
  readJsonConfigFile,
189400
188583
  readJsonOrUndefined,
189401
- realizeDiagnostics,
189402
188584
  reduceEachLeadingCommentRange,
189403
188585
  reduceEachTrailingCommentRange,
189404
188586
  reduceLeft,