@typescript-deploys/pr-build 5.5.0-pr-58243-49 → 5.5.0-pr-58380-2

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
@@ -11330,6 +11330,16 @@ var Diagnostics = {
11330
11330
  Export_0_from_module_1: diag(90059, 3 /* Message */, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
11331
11331
  Export_all_referenced_locals: diag(90060, 3 /* Message */, "Export_all_referenced_locals_90060", "Export all referenced locals"),
11332
11332
  Update_modifiers_of_0: diag(90061, 3 /* Message */, "Update_modifiers_of_0_90061", "Update modifiers of '{0}'"),
11333
+ Add_annotation_of_type_0: diag(90062, 3 /* Message */, "Add_annotation_of_type_0_90062", "Add annotation of type '{0}'"),
11334
+ Add_return_type_0: diag(90063, 3 /* Message */, "Add_return_type_0_90063", "Add return type '{0}'"),
11335
+ Extract_base_class_to_variable: diag(90064, 3 /* Message */, "Extract_base_class_to_variable_90064", "Extract base class to variable"),
11336
+ Extract_default_export_to_variable: diag(90065, 3 /* Message */, "Extract_default_export_to_variable_90065", "Extract default export to variable"),
11337
+ Extract_binding_expressions_to_variable: diag(90066, 3 /* Message */, "Extract_binding_expressions_to_variable_90066", "Extract binding expressions to variable"),
11338
+ Add_all_missing_type_annotations: diag(90067, 3 /* Message */, "Add_all_missing_type_annotations_90067", "Add all missing type annotations"),
11339
+ Add_satisfies_and_an_inline_type_assertion_with_0: diag(90068, 3 /* Message */, "Add_satisfies_and_an_inline_type_assertion_with_0_90068", "Add satisfies and an inline type assertion with '{0}'"),
11340
+ Extract_to_variable_and_replace_with_0_as_typeof_0: diag(90069, 3 /* Message */, "Extract_to_variable_and_replace_with_0_as_typeof_0_90069", "Extract to variable and replace with '{0} as typeof {0}'"),
11341
+ Mark_array_literal_as_const: diag(90070, 3 /* Message */, "Mark_array_literal_as_const_90070", "Mark array literal as const"),
11342
+ Annotate_types_of_properties_expando_function_in_a_namespace: diag(90071, 3 /* Message */, "Annotate_types_of_properties_expando_function_in_a_namespace_90071", "Annotate types of properties expando function in a namespace"),
11333
11343
  Convert_function_to_an_ES2015_class: diag(95001, 3 /* Message */, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
11334
11344
  Convert_0_to_1_in_0: diag(95003, 3 /* Message */, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
11335
11345
  Extract_to_0_in_1: diag(95004, 3 /* Message */, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -48845,7 +48855,7 @@ function createBinder() {
48845
48855
  const reportError = (
48846
48856
  // report error on all statements except empty ones
48847
48857
  isStatementButNotDeclaration(node) && node.kind !== 242 /* EmptyStatement */ || // report error on class declarations
48848
- node.kind === 263 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set
48858
+ node.kind === 263 /* ClassDeclaration */ || node.kind === 266 /* EnumDeclaration */ && (!isEnumConst(node) || shouldPreserveConstEnums(options)) || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set
48849
48859
  node.kind === 267 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)
48850
48860
  );
48851
48861
  if (reportError) {
@@ -50243,7 +50253,7 @@ function createTypeChecker(host) {
50243
50253
  var externalHelpersModule;
50244
50254
  var scanner2;
50245
50255
  var Symbol47 = objectAllocator.getSymbolConstructor();
50246
- var Type28 = objectAllocator.getTypeConstructor();
50256
+ var Type29 = objectAllocator.getTypeConstructor();
50247
50257
  var Signature14 = objectAllocator.getSignatureConstructor();
50248
50258
  var typeCount = 0;
50249
50259
  var symbolCount = 0;
@@ -50385,6 +50395,7 @@ function createTypeChecker(host) {
50385
50395
  getBaseTypes,
50386
50396
  getBaseTypeOfLiteralType,
50387
50397
  getWidenedType,
50398
+ getWidenedLiteralType,
50388
50399
  getTypeFromTypeNode: (nodeIn) => {
50389
50400
  const node = getParseTreeNode(nodeIn, isTypeNode);
50390
50401
  return node ? getTypeFromTypeNode(node) : errorType;
@@ -50613,14 +50624,6 @@ function createTypeChecker(host) {
50613
50624
  return void 0;
50614
50625
  return type;
50615
50626
  },
50616
- createTypeReference: (target, typeArguments) => {
50617
- if (target !== emptyGenericType && getObjectFlags(target) & 3 /* ClassOrInterface */) {
50618
- const interfaceType = target;
50619
- if (some(interfaceType.typeParameters)) {
50620
- return createTypeReference(interfaceType, typeArguments);
50621
- }
50622
- }
50623
- },
50624
50627
  isSymbolAccessible,
50625
50628
  isArrayType,
50626
50629
  isTupleType,
@@ -51091,6 +51094,7 @@ function createTypeChecker(host) {
51091
51094
  };
51092
51095
  var anyIterationTypes = createIterationTypes(anyType, anyType, anyType);
51093
51096
  var anyIterationTypesExceptNext = createIterationTypes(anyType, anyType, unknownType);
51097
+ var defaultIterationTypes = createIterationTypes(neverType, anyType, undefinedType);
51094
51098
  var asyncIterationTypesResolver = {
51095
51099
  iterableCacheKey: "iterationTypesOfAsyncIterable",
51096
51100
  iteratorCacheKey: "iterationTypesOfAsyncIterator",
@@ -53843,7 +53847,7 @@ function createTypeChecker(host) {
53843
53847
  }
53844
53848
  function createType(flags) {
53845
53849
  var _a;
53846
- const result = new Type28(checker, flags);
53850
+ const result = new Type29(checker, flags);
53847
53851
  typeCount++;
53848
53852
  result.id = typeCount;
53849
53853
  (_a = tracing) == null ? void 0 : _a.recordType(result);
@@ -53855,7 +53859,7 @@ function createTypeChecker(host) {
53855
53859
  return result;
53856
53860
  }
53857
53861
  function createOriginType(flags) {
53858
- return new Type28(checker, flags);
53862
+ return new Type29(checker, flags);
53859
53863
  }
53860
53864
  function createIntrinsicType(kind, intrinsicName, objectFlags = 0 /* None */, debugIntrinsicName) {
53861
53865
  checkIntrinsicName(intrinsicName, debugIntrinsicName);
@@ -54453,31 +54457,31 @@ function createTypeChecker(host) {
54453
54457
  }
54454
54458
  function createNodeBuilder() {
54455
54459
  return {
54456
- typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
54457
- typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
54458
- expressionOrTypeToTypeNode: (expr, type, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => expressionOrTypeToTypeNode(context, expr, type, addUndefined)),
54459
- serializeTypeForDeclaration: (declaration, type, symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(context, declaration, type, symbol)),
54460
- serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeReturnTypeForSignature(context, signature)),
54461
- indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
54460
+ typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
54461
+ typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
54462
+ expressionOrTypeToTypeNode: (expr, type, addUndefined, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => expressionOrTypeToTypeNode(context, expr, type, addUndefined)),
54463
+ serializeTypeForDeclaration: (declaration, type, symbol, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(context, declaration, type, symbol)),
54464
+ serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => serializeReturnTypeForSignature(context, signature)),
54465
+ indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
54462
54466
  indexInfo,
54463
54467
  context,
54464
54468
  /*typeNode*/
54465
54469
  void 0
54466
54470
  )),
54467
- signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => signatureToSignatureDeclarationHelper(signature, kind, context)),
54468
- symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToName(
54471
+ signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => signatureToSignatureDeclarationHelper(signature, kind, context)),
54472
+ symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolToName(
54469
54473
  symbol,
54470
54474
  context,
54471
54475
  meaning,
54472
54476
  /*expectsIdentifier*/
54473
54477
  false
54474
54478
  )),
54475
- symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToExpression(symbol, context, meaning)),
54476
- symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
54477
- symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
54478
- typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
54479
- symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
54480
- symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
54479
+ symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolToExpression(symbol, context, meaning)),
54480
+ symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
54481
+ symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
54482
+ typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
54483
+ symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
54484
+ symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
54481
54485
  };
54482
54486
  function setTextRange2(context, range, location) {
54483
54487
  if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
@@ -54560,7 +54564,7 @@ function createTypeChecker(host) {
54560
54564
  }
54561
54565
  return symbolToExpression(symbol, context, meaning);
54562
54566
  }
54563
- function withContext(enclosingDeclaration, flags, tracker, cb) {
54567
+ function withContext2(enclosingDeclaration, flags, tracker, cb) {
54564
54568
  Debug.assert(enclosingDeclaration === void 0 || (enclosingDeclaration.flags & 16 /* Synthesized */) === 0);
54565
54569
  const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : flags & 134217728 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
54566
54570
  const context = {
@@ -55229,36 +55233,7 @@ function createTypeChecker(host) {
55229
55233
  }
55230
55234
  let typeArgumentNodes;
55231
55235
  if (typeArguments.length > 0) {
55232
- let typeParameterCount;
55233
- if (type2.target.typeParameters) {
55234
- typeParameterCount = Math.min(type2.target.typeParameters.length, typeArguments.length);
55235
- if (isReferenceToType2(type2, getGlobalIterableType(
55236
- /*reportErrors*/
55237
- false
55238
- )) || isReferenceToType2(type2, getGlobalIterableIteratorType(
55239
- /*reportErrors*/
55240
- false
55241
- )) || isReferenceToType2(type2, getGlobalAsyncIterableType(
55242
- /*reportErrors*/
55243
- false
55244
- )) || isReferenceToType2(type2, getGlobalAsyncIterableIteratorType(
55245
- /*reportErrors*/
55246
- false
55247
- ))) {
55248
- if (!type2.node || !isTypeReferenceNode(type2.node) || !type2.node.typeArguments || type2.node.typeArguments.length < typeParameterCount) {
55249
- while (typeParameterCount > 0) {
55250
- const typeArgument = typeArguments[typeParameterCount - 1];
55251
- const defaultType = getDefaultFromTypeParameter(type2.target.typeParameters[typeParameterCount - 1]);
55252
- if (!defaultType || !isTypeIdenticalTo(typeArgument, defaultType)) {
55253
- break;
55254
- }
55255
- typeParameterCount--;
55256
- }
55257
- }
55258
- }
55259
- } else {
55260
- typeParameterCount = 0;
55261
- }
55236
+ const typeParameterCount = (type2.target.typeParameters || emptyArray).length;
55262
55237
  typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
55263
55238
  }
55264
55239
  const flags = context.flags;
@@ -63588,7 +63563,7 @@ function createTypeChecker(host) {
63588
63563
  return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType(
63589
63564
  "AsyncIterable",
63590
63565
  /*arity*/
63591
- 3,
63566
+ 1,
63592
63567
  reportErrors2
63593
63568
  )) || emptyGenericType;
63594
63569
  }
@@ -63604,7 +63579,7 @@ function createTypeChecker(host) {
63604
63579
  return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType(
63605
63580
  "AsyncIterableIterator",
63606
63581
  /*arity*/
63607
- 3,
63582
+ 1,
63608
63583
  reportErrors2
63609
63584
  )) || emptyGenericType;
63610
63585
  }
@@ -63620,7 +63595,7 @@ function createTypeChecker(host) {
63620
63595
  return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType(
63621
63596
  "Iterable",
63622
63597
  /*arity*/
63623
- 3,
63598
+ 1,
63624
63599
  reportErrors2
63625
63600
  )) || emptyGenericType;
63626
63601
  }
@@ -63636,7 +63611,7 @@ function createTypeChecker(host) {
63636
63611
  return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType(
63637
63612
  "IterableIterator",
63638
63613
  /*arity*/
63639
- 3,
63614
+ 1,
63640
63615
  reportErrors2
63641
63616
  )) || emptyGenericType;
63642
63617
  }
@@ -63818,7 +63793,7 @@ function createTypeChecker(host) {
63818
63793
  return createTypeFromGenericGlobalType(getGlobalIterableType(
63819
63794
  /*reportErrors*/
63820
63795
  true
63821
- ), [iteratedType, voidType, undefinedType]);
63796
+ ), [iteratedType]);
63822
63797
  }
63823
63798
  function createArrayType(elementType, readonly) {
63824
63799
  return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]);
@@ -75638,60 +75613,71 @@ function createTypeChecker(host) {
75638
75613
  return false;
75639
75614
  }
75640
75615
  function discriminateContextualTypeByObjectMembers(node, contextualType) {
75641
- return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(
75642
- contextualType,
75643
- concatenate(
75644
- map(
75645
- filter(node.properties, (p) => {
75646
- if (!p.symbol) {
75616
+ const key = `D${getNodeId(node)},${getTypeId(contextualType)}`;
75617
+ return getCachedType(key) ?? setCachedType(
75618
+ key,
75619
+ getMatchingUnionConstituentForObjectLiteral(contextualType, node) ?? discriminateTypeByDiscriminableItems(
75620
+ contextualType,
75621
+ concatenate(
75622
+ map(
75623
+ filter(node.properties, (p) => {
75624
+ if (!p.symbol) {
75625
+ return false;
75626
+ }
75627
+ if (p.kind === 303 /* PropertyAssignment */) {
75628
+ return isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName);
75629
+ }
75630
+ if (p.kind === 304 /* ShorthandPropertyAssignment */) {
75631
+ return isDiscriminantProperty(contextualType, p.symbol.escapedName);
75632
+ }
75647
75633
  return false;
75648
- }
75649
- if (p.kind === 303 /* PropertyAssignment */) {
75650
- return isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName);
75651
- }
75652
- if (p.kind === 304 /* ShorthandPropertyAssignment */) {
75653
- return isDiscriminantProperty(contextualType, p.symbol.escapedName);
75654
- }
75655
- return false;
75656
- }),
75657
- (prop) => [() => getContextFreeTypeOfExpression(prop.kind === 303 /* PropertyAssignment */ ? prop.initializer : prop.name), prop.symbol.escapedName]
75634
+ }),
75635
+ (prop) => [() => getContextFreeTypeOfExpression(prop.kind === 303 /* PropertyAssignment */ ? prop.initializer : prop.name), prop.symbol.escapedName]
75636
+ ),
75637
+ map(
75638
+ filter(getPropertiesOfType(contextualType), (s) => {
75639
+ var _a;
75640
+ return !!(s.flags & 16777216 /* Optional */) && !!((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
75641
+ }),
75642
+ (s) => [() => undefinedType, s.escapedName]
75643
+ )
75658
75644
  ),
75659
- map(
75660
- filter(getPropertiesOfType(contextualType), (s) => {
75661
- var _a;
75662
- return !!(s.flags & 16777216 /* Optional */) && !!((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
75663
- }),
75664
- (s) => [() => undefinedType, s.escapedName]
75665
- )
75666
- ),
75667
- isTypeAssignableTo
75645
+ isTypeAssignableTo
75646
+ )
75668
75647
  );
75669
75648
  }
75670
75649
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
75650
+ const key = `D${getNodeId(node)},${getTypeId(contextualType)}`;
75651
+ const cached = getCachedType(key);
75652
+ if (cached)
75653
+ return cached;
75671
75654
  const jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
75672
- return discriminateTypeByDiscriminableItems(
75673
- contextualType,
75674
- concatenate(
75675
- map(
75676
- filter(node.properties, (p) => !!p.symbol && p.kind === 291 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer))),
75677
- (prop) => [!prop.initializer ? () => trueType : () => getContextFreeTypeOfExpression(prop.initializer), prop.symbol.escapedName]
75655
+ return setCachedType(
75656
+ key,
75657
+ discriminateTypeByDiscriminableItems(
75658
+ contextualType,
75659
+ concatenate(
75660
+ map(
75661
+ filter(node.properties, (p) => !!p.symbol && p.kind === 291 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer))),
75662
+ (prop) => [!prop.initializer ? () => trueType : () => getContextFreeTypeOfExpression(prop.initializer), prop.symbol.escapedName]
75663
+ ),
75664
+ map(
75665
+ filter(getPropertiesOfType(contextualType), (s) => {
75666
+ var _a;
75667
+ if (!(s.flags & 16777216 /* Optional */) || !((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members)) {
75668
+ return false;
75669
+ }
75670
+ const element = node.parent.parent;
75671
+ if (s.escapedName === jsxChildrenPropertyName && isJsxElement(element) && getSemanticJsxChildren(element.children).length) {
75672
+ return false;
75673
+ }
75674
+ return !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
75675
+ }),
75676
+ (s) => [() => undefinedType, s.escapedName]
75677
+ )
75678
75678
  ),
75679
- map(
75680
- filter(getPropertiesOfType(contextualType), (s) => {
75681
- var _a;
75682
- if (!(s.flags & 16777216 /* Optional */) || !((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members)) {
75683
- return false;
75684
- }
75685
- const element = node.parent.parent;
75686
- if (s.escapedName === jsxChildrenPropertyName && isJsxElement(element) && getSemanticJsxChildren(element.children).length) {
75687
- return false;
75688
- }
75689
- return !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
75690
- }),
75691
- (s) => [() => undefinedType, s.escapedName]
75692
- )
75693
- ),
75694
- isTypeAssignableTo
75679
+ isTypeAssignableTo
75680
+ )
75695
75681
  );
75696
75682
  }
75697
75683
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -81045,14 +81031,24 @@ function createTypeChecker(host) {
81045
81031
  void 0
81046
81032
  ) || unknownType;
81047
81033
  if (globalGeneratorType === emptyGenericType) {
81048
- const globalIterableIteratorType = resolver.getGlobalIterableIteratorType(
81034
+ const globalType = resolver.getGlobalIterableIteratorType(
81049
81035
  /*reportErrors*/
81050
81036
  false
81051
81037
  );
81052
- if (globalIterableIteratorType !== emptyGenericType) {
81053
- return createTypeFromGenericGlobalType(globalIterableIteratorType, [yieldType, returnType, nextType]);
81038
+ const iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : void 0;
81039
+ const iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType;
81040
+ const iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType;
81041
+ if (isTypeAssignableTo(returnType, iterableIteratorReturnType) && isTypeAssignableTo(iterableIteratorNextType, nextType)) {
81042
+ if (globalType !== emptyGenericType) {
81043
+ return createTypeFromGenericGlobalType(globalType, [yieldType]);
81044
+ }
81045
+ resolver.getGlobalIterableIteratorType(
81046
+ /*reportErrors*/
81047
+ true
81048
+ );
81049
+ return emptyObjectType;
81054
81050
  }
81055
- resolver.getGlobalIterableIteratorType(
81051
+ resolver.getGlobalGeneratorType(
81056
81052
  /*reportErrors*/
81057
81053
  true
81058
81054
  );
@@ -86188,14 +86184,41 @@ function createTypeChecker(host) {
86188
86184
  function getIterationTypesOfIterableCached(type, resolver) {
86189
86185
  return getCachedIterationTypes(type, resolver.iterableCacheKey);
86190
86186
  }
86187
+ function getIterationTypesOfGlobalIterableType(globalType, resolver) {
86188
+ const globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) || getIterationTypesOfIterableSlow(
86189
+ globalType,
86190
+ resolver,
86191
+ /*errorNode*/
86192
+ void 0,
86193
+ /*errorOutputContainer*/
86194
+ void 0,
86195
+ /*noCache*/
86196
+ false
86197
+ );
86198
+ return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
86199
+ }
86191
86200
  function getIterationTypesOfIterableFast(type, resolver) {
86192
- if (isReferenceToType2(type, resolver.getGlobalIterableType(
86201
+ let globalType;
86202
+ if (isReferenceToType2(type, globalType = resolver.getGlobalIterableType(
86193
86203
  /*reportErrors*/
86194
86204
  false
86195
- )) || isReferenceToType2(type, resolver.getGlobalIterableIteratorType(
86205
+ )) || isReferenceToType2(type, globalType = resolver.getGlobalIterableIteratorType(
86196
86206
  /*reportErrors*/
86197
86207
  false
86198
- )) || isReferenceToType2(type, resolver.getGlobalGeneratorType(
86208
+ ))) {
86209
+ const [yieldType] = getTypeArguments(type);
86210
+ const { returnType, nextType } = getIterationTypesOfGlobalIterableType(globalType, resolver);
86211
+ return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(resolver.resolveIterationType(
86212
+ yieldType,
86213
+ /*errorNode*/
86214
+ void 0
86215
+ ) || yieldType, resolver.resolveIterationType(
86216
+ returnType,
86217
+ /*errorNode*/
86218
+ void 0
86219
+ ) || returnType, nextType));
86220
+ }
86221
+ if (isReferenceToType2(type, resolver.getGlobalGeneratorType(
86199
86222
  /*reportErrors*/
86200
86223
  false
86201
86224
  ))) {
@@ -86240,10 +86263,10 @@ function createTypeChecker(host) {
86240
86263
  !!getAwaitedTypeOfPromise(type) || !allowAsyncIterables && isForOfStatement(errorNode.parent) && errorNode.parent.expression === errorNode && getGlobalAsyncIterableType(
86241
86264
  /*reportErrors*/
86242
86265
  false
86243
- ) !== emptyGenericType && isTypeAssignableTo(type, createTypeFromGenericGlobalType(getGlobalAsyncIterableType(
86266
+ ) !== emptyGenericType && isTypeAssignableTo(type, getGlobalAsyncIterableType(
86244
86267
  /*reportErrors*/
86245
86268
  false
86246
- ), [anyType, anyType, anyType]))
86269
+ ))
86247
86270
  );
86248
86271
  return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
86249
86272
  }
@@ -86273,10 +86296,26 @@ function createTypeChecker(host) {
86273
86296
  return getCachedIterationTypes(type, resolver.iteratorCacheKey);
86274
86297
  }
86275
86298
  function getIterationTypesOfIteratorFast(type, resolver) {
86276
- if (isReferenceToType2(type, resolver.getGlobalIterableIteratorType(
86299
+ const globalType = resolver.getGlobalIterableIteratorType(
86277
86300
  /*reportErrors*/
86278
86301
  false
86279
- )) || isReferenceToType2(type, resolver.getGlobalIteratorType(
86302
+ );
86303
+ if (isReferenceToType2(type, globalType)) {
86304
+ const [yieldType] = getTypeArguments(type);
86305
+ const globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || getIterationTypesOfIteratorSlow(
86306
+ globalType,
86307
+ resolver,
86308
+ /*errorNode*/
86309
+ void 0,
86310
+ /*errorOutputContainer*/
86311
+ void 0,
86312
+ /*noCache*/
86313
+ false
86314
+ );
86315
+ const { returnType, nextType } = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
86316
+ return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
86317
+ }
86318
+ if (isReferenceToType2(type, resolver.getGlobalIteratorType(
86280
86319
  /*reportErrors*/
86281
86320
  false
86282
86321
  )) || isReferenceToType2(type, resolver.getGlobalGeneratorType(
@@ -142853,6 +142892,7 @@ __export(ts_refactor_exports, {
142853
142892
  generateGetAccessorAndSetAccessor: () => ts_refactor_generateGetAccessorAndSetAccessor_exports,
142854
142893
  getApplicableRefactors: () => getApplicableRefactors,
142855
142894
  getEditsForRefactor: () => getEditsForRefactor,
142895
+ getIdentifierForNode: () => getIdentifierForNode,
142856
142896
  getNewStatementsAndRemoveFromOldFile: () => getNewStatementsAndRemoveFromOldFile,
142857
142897
  getStatementsToMove: () => getStatementsToMove,
142858
142898
  getTopLevelDeclarationStatement: () => getTopLevelDeclarationStatement,
@@ -144581,6 +144621,15 @@ function refactorKindBeginsWith(known, requested) {
144581
144621
  return true;
144582
144622
  return known.substr(0, requested.length) === requested;
144583
144623
  }
144624
+ function getIdentifierForNode(node, scope, checker, file) {
144625
+ return isPropertyAccessExpression(node) && !isClassLike(scope) && !checker.resolveName(
144626
+ node.name.text,
144627
+ node,
144628
+ 111551 /* Value */,
144629
+ /*excludeGlobals*/
144630
+ false
144631
+ ) && !isPrivateIdentifier(node.name) && !identifierToKeywordKind(node.name) ? node.name.text : getUniqueName(isClassLike(scope) ? "newProperty" : "newLocal", file);
144632
+ }
144584
144633
  function addTargetFileImports(oldFile, importsToCopy, targetFileImportsFromOldFile, checker, program, importAdder) {
144585
144634
  importsToCopy.forEach(([isValidTypeOnlyUseSite, declaration], symbol) => {
144586
144635
  var _a;
@@ -147264,13 +147313,7 @@ function extractFunctionInScope(node, scope, { usages: usagesInScope, typeParame
147264
147313
  function extractConstantInScope(node, scope, { substitutions }, rangeFacts, context) {
147265
147314
  const checker = context.program.getTypeChecker();
147266
147315
  const file = scope.getSourceFile();
147267
- const localNameText = isPropertyAccessExpression(node) && !isClassLike(scope) && !checker.resolveName(
147268
- node.name.text,
147269
- node,
147270
- 111551 /* Value */,
147271
- /*excludeGlobals*/
147272
- false
147273
- ) && !isPrivateIdentifier(node.name) && !identifierToKeywordKind(node.name) ? node.name.text : getUniqueName(isClassLike(scope) ? "newProperty" : "newLocal", file);
147316
+ const localNameText = getIdentifierForNode(node, scope, checker, file);
147274
147317
  const isJS = isInJSFile(scope);
147275
147318
  let variableType = isJS || !checker.isContextSensitive(node) ? void 0 : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */);
147276
147319
  let initializer = transformConstantInitializer(skipParentheses(node), substitutions);
@@ -149838,22 +149881,22 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
149838
149881
  }
149839
149882
  return [];
149840
149883
  }
149841
- function getCodeFixesAtPosition(fileName, start, end, errorCodes66, formatOptions, preferences = emptyOptions) {
149884
+ function getCodeFixesAtPosition(fileName, start, end, errorCodes67, formatOptions, preferences = emptyOptions) {
149842
149885
  synchronizeHostData();
149843
149886
  const sourceFile = getValidSourceFile(fileName);
149844
149887
  const span = createTextSpanFromBounds(start, end);
149845
149888
  const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
149846
- return flatMap(deduplicate(errorCodes66, equateValues, compareValues), (errorCode) => {
149889
+ return flatMap(deduplicate(errorCodes67, equateValues, compareValues), (errorCode) => {
149847
149890
  cancellationToken.throwIfCancellationRequested();
149848
149891
  return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
149849
149892
  });
149850
149893
  }
149851
- function getCombinedCodeFix(scope, fixId53, formatOptions, preferences = emptyOptions) {
149894
+ function getCombinedCodeFix(scope, fixId54, formatOptions, preferences = emptyOptions) {
149852
149895
  synchronizeHostData();
149853
149896
  Debug.assert(scope.type === "file");
149854
149897
  const sourceFile = getValidSourceFile(scope.fileName);
149855
149898
  const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
149856
- return ts_codefix_exports.getAllFixes({ fixId: fixId53, sourceFile, program, host, cancellationToken, formatContext, preferences });
149899
+ return ts_codefix_exports.getAllFixes({ fixId: fixId54, sourceFile, program, host, cancellationToken, formatContext, preferences });
149857
149900
  }
149858
149901
  function organizeImports2(args, formatOptions, preferences = emptyOptions) {
149859
149902
  synchronizeHostData();
@@ -151532,14 +151575,14 @@ function createCodeFixActionWithoutFixAll(fixName8, changes, description3) {
151532
151575
  void 0
151533
151576
  );
151534
151577
  }
151535
- function createCodeFixAction(fixName8, changes, description3, fixId53, fixAllDescription, command) {
151536
- return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId53, diagnosticToString(fixAllDescription), command);
151578
+ function createCodeFixAction(fixName8, changes, description3, fixId54, fixAllDescription, command) {
151579
+ return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId54, diagnosticToString(fixAllDescription), command);
151537
151580
  }
151538
- function createCodeFixActionMaybeFixAll(fixName8, changes, description3, fixId53, fixAllDescription, command) {
151539
- return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId53, fixAllDescription && diagnosticToString(fixAllDescription), command);
151581
+ function createCodeFixActionMaybeFixAll(fixName8, changes, description3, fixId54, fixAllDescription, command) {
151582
+ return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId54, fixAllDescription && diagnosticToString(fixAllDescription), command);
151540
151583
  }
151541
- function createCodeFixActionWorker(fixName8, description3, changes, fixId53, fixAllDescription, command) {
151542
- return { fixName: fixName8, description: description3, changes, fixId: fixId53, fixAllDescription, commands: command ? [command] : void 0 };
151584
+ function createCodeFixActionWorker(fixName8, description3, changes, fixId54, fixAllDescription, command) {
151585
+ return { fixName: fixName8, description: description3, changes, fixId: fixId54, fixAllDescription, commands: command ? [command] : void 0 };
151543
151586
  }
151544
151587
  function registerCodeFix(reg) {
151545
151588
  for (const error2 of reg.errorCodes) {
@@ -151547,9 +151590,9 @@ function registerCodeFix(reg) {
151547
151590
  errorCodeToFixes.add(String(error2), reg);
151548
151591
  }
151549
151592
  if (reg.fixIds) {
151550
- for (const fixId53 of reg.fixIds) {
151551
- Debug.assert(!fixIdToRegistration.has(fixId53));
151552
- fixIdToRegistration.set(fixId53, reg);
151593
+ for (const fixId54 of reg.fixIds) {
151594
+ Debug.assert(!fixIdToRegistration.has(fixId54));
151595
+ fixIdToRegistration.set(fixId54, reg);
151553
151596
  }
151554
151597
  }
151555
151598
  }
@@ -151558,17 +151601,17 @@ function getSupportedErrorCodes() {
151558
151601
  return errorCodeToFixesArray ?? (errorCodeToFixesArray = arrayFrom(errorCodeToFixes.keys()));
151559
151602
  }
151560
151603
  function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
151561
- const { errorCodes: errorCodes66 } = registration;
151604
+ const { errorCodes: errorCodes67 } = registration;
151562
151605
  let maybeFixableDiagnostics = 0;
151563
151606
  for (const diag2 of diagnostics) {
151564
- if (contains(errorCodes66, diag2.code))
151607
+ if (contains(errorCodes67, diag2.code))
151565
151608
  maybeFixableDiagnostics++;
151566
151609
  if (maybeFixableDiagnostics > 1)
151567
151610
  break;
151568
151611
  }
151569
151612
  const fixAllUnavailable = maybeFixableDiagnostics < 2;
151570
- return ({ fixId: fixId53, fixAllDescription, ...action }) => {
151571
- return fixAllUnavailable ? action : { ...action, fixId: fixId53, fixAllDescription };
151613
+ return ({ fixId: fixId54, fixAllDescription, ...action }) => {
151614
+ return fixAllUnavailable ? action : { ...action, fixId: fixId54, fixAllDescription };
151572
151615
  };
151573
151616
  }
151574
151617
  function getFixes(context) {
@@ -151585,24 +151628,30 @@ function createCombinedCodeActions(changes, commands) {
151585
151628
  function createFileTextChanges(fileName, textChanges2) {
151586
151629
  return { fileName, textChanges: textChanges2 };
151587
151630
  }
151588
- function codeFixAll(context, errorCodes66, use) {
151631
+ function codeFixAll(context, errorCodes67, use) {
151589
151632
  const commands = [];
151590
- const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes66, (diag2) => use(t, diag2, commands)));
151633
+ const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes67, (diag2) => use(t, diag2, commands)));
151591
151634
  return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
151592
151635
  }
151593
- function eachDiagnostic(context, errorCodes66, cb) {
151636
+ function eachDiagnostic(context, errorCodes67, cb) {
151594
151637
  for (const diag2 of getDiagnostics(context)) {
151595
- if (contains(errorCodes66, diag2.code)) {
151638
+ if (contains(errorCodes67, diag2.code)) {
151596
151639
  cb(diag2);
151597
151640
  }
151598
151641
  }
151599
151642
  }
151600
151643
  function getDiagnostics({ program, sourceFile, cancellationToken }) {
151601
- return [
151644
+ const diagnostics = [
151602
151645
  ...program.getSemanticDiagnostics(sourceFile, cancellationToken),
151603
151646
  ...program.getSyntacticDiagnostics(sourceFile, cancellationToken),
151604
151647
  ...computeSuggestionDiagnostics(sourceFile, program, cancellationToken)
151605
151648
  ];
151649
+ if (getEmitDeclarations(program.getCompilerOptions())) {
151650
+ diagnostics.push(
151651
+ ...program.getDeclarationDiagnostics(sourceFile, cancellationToken)
151652
+ );
151653
+ }
151654
+ return diagnostics;
151606
151655
  }
151607
151656
 
151608
151657
  // src/services/codefixes/addConvertToUnknownForNonOverlappingTypes.ts
@@ -151901,9 +151950,7 @@ function makeChange3(changeTracker, errorCode, sourceFile, checker, insertionSit
151901
151950
  if (isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
151902
151951
  const exprType = checker.getTypeAtLocation(insertionSite);
151903
151952
  const asyncIter = checker.getAsyncIterableType();
151904
- const anyType = checker.getAnyType();
151905
- const asyncIterInstantiation = asyncIter && checker.createTypeReference(asyncIter, [anyType, anyType, anyType]);
151906
- if (asyncIterInstantiation && checker.isTypeAssignableTo(exprType, asyncIterInstantiation)) {
151953
+ if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
151907
151954
  const forOf = insertionSite.parent;
151908
151955
  changeTracker.replaceNode(sourceFile, forOf, factory.updateForOfStatement(forOf, factory.createToken(135 /* AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
151909
151956
  return;
@@ -156292,10 +156339,10 @@ registerCodeFix({
156292
156339
  const info = errorCodeFixIdMap[errorCode];
156293
156340
  if (!info)
156294
156341
  return emptyArray;
156295
- const { descriptions, fixId: fixId53, fixAllDescriptions } = info;
156342
+ const { descriptions, fixId: fixId54, fixAllDescriptions } = info;
156296
156343
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
156297
156344
  return [
156298
- createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId53, fixAllDescriptions)
156345
+ createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId54, fixAllDescriptions)
156299
156346
  ];
156300
156347
  },
156301
156348
  fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
@@ -157100,7 +157147,7 @@ registerCodeFix({
157100
157147
  },
157101
157148
  fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
157102
157149
  getAllCodeActions: (context) => {
157103
- const { program, fixId: fixId53 } = context;
157150
+ const { program, fixId: fixId54 } = context;
157104
157151
  const checker = program.getTypeChecker();
157105
157152
  const seen = /* @__PURE__ */ new Map();
157106
157153
  const typeDeclToMembers = /* @__PURE__ */ new Map();
@@ -157110,11 +157157,11 @@ registerCodeFix({
157110
157157
  if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + (info.kind === 3 /* ObjectLiteral */ ? info.identifier : info.token.text))) {
157111
157158
  return;
157112
157159
  }
157113
- if (fixId53 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
157160
+ if (fixId54 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
157114
157161
  addFunctionDeclaration(changes, context, info);
157115
- } else if (fixId53 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
157162
+ } else if (fixId54 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
157116
157163
  addObjectLiteralProperties(changes, context, info);
157117
- } else if (fixId53 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
157164
+ } else if (fixId54 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
157118
157165
  addJsxAttributes(changes, context, info);
157119
157166
  } else {
157120
157167
  if (info.kind === 1 /* Enum */) {
@@ -159036,21 +159083,21 @@ registerCodeFix({
159036
159083
  actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
159037
159084
  }
159038
159085
  return actions2;
159039
- function fix(type2, fixId53, fixAllDescription) {
159086
+ function fix(type2, fixId54, fixAllDescription) {
159040
159087
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, typeNode, type2, checker));
159041
- return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId53, fixAllDescription);
159088
+ return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId54, fixAllDescription);
159042
159089
  }
159043
159090
  },
159044
159091
  fixIds: [fixIdPlain, fixIdNullable],
159045
159092
  getAllCodeActions(context) {
159046
- const { fixId: fixId53, program, sourceFile } = context;
159093
+ const { fixId: fixId54, program, sourceFile } = context;
159047
159094
  const checker = program.getTypeChecker();
159048
159095
  return codeFixAll(context, errorCodes45, (changes, err) => {
159049
159096
  const info = getInfo15(err.file, err.start, checker);
159050
159097
  if (!info)
159051
159098
  return;
159052
159099
  const { typeNode, type } = info;
159053
- const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId53 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
159100
+ const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId54 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
159054
159101
  doChange29(changes, sourceFile, typeNode, fixedType, checker);
159055
159102
  });
159056
159103
  }
@@ -159145,28 +159192,909 @@ function getCallName(sourceFile, start) {
159145
159192
  return void 0;
159146
159193
  }
159147
159194
 
159148
- // src/services/codefixes/fixAwaitInSyncFunction.ts
159149
- var fixId36 = "fixAwaitInSyncFunction";
159195
+ // src/services/codefixes/fixMissingTypeAnnotationOnExports.ts
159196
+ var fixId36 = "fixMissingTypeAnnotationOnExports";
159197
+ var addAnnotationFix = "add-annotation";
159198
+ var addInlineTypeAssertion = "add-type-assertion";
159199
+ var extractExpression = "extract-expression";
159150
159200
  var errorCodes47 = [
159201
+ Diagnostics.Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
159202
+ Diagnostics.Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
159203
+ Diagnostics.At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
159204
+ Diagnostics.Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations.code,
159205
+ Diagnostics.Parameter_must_have_an_explicit_type_annotation_with_isolatedDeclarations.code,
159206
+ Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations.code,
159207
+ Diagnostics.Expression_type_can_t_be_inferred_with_isolatedDeclarations.code,
159208
+ Diagnostics.Binding_elements_can_t_be_exported_directly_with_isolatedDeclarations.code,
159209
+ Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations.code,
159210
+ Diagnostics.Enum_member_initializers_must_be_computable_without_references_to_external_symbols_with_isolatedDeclarations.code,
159211
+ Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations.code,
159212
+ Diagnostics.Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations.code,
159213
+ Diagnostics.Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations.code,
159214
+ Diagnostics.Arrays_with_spread_elements_can_t_inferred_with_isolatedDeclarations.code,
159215
+ Diagnostics.Default_exports_can_t_be_inferred_with_isolatedDeclarations.code,
159216
+ Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations.code,
159217
+ Diagnostics.Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations_Add_an_explicit_declaration_for_the_properties_assigned_to_this_function.code,
159218
+ Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_supported_with_isolatedDeclarations.code,
159219
+ Diagnostics.Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit.code
159220
+ ];
159221
+ var canHaveTypeAnnotation = /* @__PURE__ */ new Set([
159222
+ 177 /* GetAccessor */,
159223
+ 174 /* MethodDeclaration */,
159224
+ 172 /* PropertyDeclaration */,
159225
+ 262 /* FunctionDeclaration */,
159226
+ 218 /* FunctionExpression */,
159227
+ 219 /* ArrowFunction */,
159228
+ 260 /* VariableDeclaration */,
159229
+ 169 /* Parameter */,
159230
+ 277 /* ExportAssignment */,
159231
+ 263 /* ClassDeclaration */,
159232
+ 206 /* ObjectBindingPattern */,
159233
+ 207 /* ArrayBindingPattern */
159234
+ ]);
159235
+ var declarationEmitNodeBuilderFlags2 = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */ | 1073741824 /* WriteComputedProps */;
159236
+ registerCodeFix({
159237
+ errorCodes: errorCodes47,
159238
+ fixIds: [fixId36],
159239
+ getCodeActions(context) {
159240
+ const fixes = [];
159241
+ addCodeAction(addAnnotationFix, fixes, context, 0 /* Full */, (f) => f.addTypeAnnotation(context.span));
159242
+ addCodeAction(addAnnotationFix, fixes, context, 1 /* Relative */, (f) => f.addTypeAnnotation(context.span));
159243
+ addCodeAction(addAnnotationFix, fixes, context, 2 /* Widened */, (f) => f.addTypeAnnotation(context.span));
159244
+ addCodeAction(addInlineTypeAssertion, fixes, context, 0 /* Full */, (f) => f.addInlineAssertion(context.span));
159245
+ addCodeAction(addInlineTypeAssertion, fixes, context, 1 /* Relative */, (f) => f.addInlineAssertion(context.span));
159246
+ addCodeAction(addAnnotationFix, fixes, context, 2 /* Widened */, (f) => f.addInlineAssertion(context.span));
159247
+ addCodeAction(extractExpression, fixes, context, 0 /* Full */, (f) => f.extractAsVariable(context.span));
159248
+ return fixes;
159249
+ },
159250
+ getAllCodeActions: (context) => {
159251
+ const changes = withContext(context, 0 /* Full */, (f) => {
159252
+ eachDiagnostic(context, errorCodes47, (diag2) => {
159253
+ f.addTypeAnnotation(diag2);
159254
+ });
159255
+ });
159256
+ return createCombinedCodeActions(changes.textChanges);
159257
+ }
159258
+ });
159259
+ function addCodeAction(fixName8, fixes, context, typePrintMode, cb) {
159260
+ const changes = withContext(context, typePrintMode, cb);
159261
+ if (changes.result && changes.textChanges.length) {
159262
+ fixes.push(createCodeFixAction(
159263
+ fixName8,
159264
+ changes.textChanges,
159265
+ changes.result,
159266
+ fixId36,
159267
+ Diagnostics.Add_all_missing_type_annotations
159268
+ ));
159269
+ }
159270
+ }
159271
+ function withContext(context, typePrintMode, cb) {
159272
+ const emptyInferenceResult = { typeNode: void 0, mutatedTarget: false };
159273
+ const changeTracker = ts_textChanges_exports.ChangeTracker.fromContext(context);
159274
+ const sourceFile = context.sourceFile;
159275
+ const program = context.program;
159276
+ const typeChecker = program.getTypeChecker();
159277
+ const emitResolver = typeChecker.getEmitResolver();
159278
+ const scriptTarget = getEmitScriptTarget(program.getCompilerOptions());
159279
+ const importAdder = createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
159280
+ const fixedNodes = /* @__PURE__ */ new Set();
159281
+ const expandoPropertiesAdded = /* @__PURE__ */ new Set();
159282
+ const typePrinter = createPrinter({
159283
+ preserveSourceNewlines: false
159284
+ });
159285
+ const result = cb({ addTypeAnnotation, addInlineAssertion, extractAsVariable });
159286
+ importAdder.writeFixes(changeTracker);
159287
+ return {
159288
+ result,
159289
+ textChanges: changeTracker.getChanges()
159290
+ };
159291
+ function addTypeAnnotation(span) {
159292
+ const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
159293
+ const expandoFunction = findExpandoFunction(nodeWithDiag);
159294
+ if (expandoFunction) {
159295
+ if (isFunctionDeclaration(expandoFunction)) {
159296
+ return createNamespaceForExpandoProperties(expandoFunction);
159297
+ }
159298
+ return fixIsolatedDeclarationError(expandoFunction);
159299
+ }
159300
+ const nodeMissingType = findAncestorWithMissingType(nodeWithDiag);
159301
+ if (nodeMissingType) {
159302
+ return fixIsolatedDeclarationError(nodeMissingType);
159303
+ }
159304
+ return void 0;
159305
+ }
159306
+ function createNamespaceForExpandoProperties(expandoFunc) {
159307
+ var _a;
159308
+ if (expandoPropertiesAdded == null ? void 0 : expandoPropertiesAdded.has(expandoFunc))
159309
+ return void 0;
159310
+ expandoPropertiesAdded == null ? void 0 : expandoPropertiesAdded.add(expandoFunc);
159311
+ const type = typeChecker.getTypeAtLocation(expandoFunc);
159312
+ const elements = typeChecker.getPropertiesOfType(type);
159313
+ if (!expandoFunc.name || elements.length === 0)
159314
+ return void 0;
159315
+ const newProperties = [];
159316
+ for (const symbol of elements) {
159317
+ if (!isIdentifierText(symbol.name, getEmitScriptTarget(program.getCompilerOptions())))
159318
+ continue;
159319
+ if (symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration))
159320
+ continue;
159321
+ newProperties.push(factory.createVariableStatement(
159322
+ [factory.createModifier(95 /* ExportKeyword */)],
159323
+ factory.createVariableDeclarationList(
159324
+ [factory.createVariableDeclaration(
159325
+ symbol.name,
159326
+ /*exclamationToken*/
159327
+ void 0,
159328
+ typeToTypeNode2(typeChecker.getTypeOfSymbol(symbol), expandoFunc),
159329
+ /*initializer*/
159330
+ void 0
159331
+ )]
159332
+ )
159333
+ ));
159334
+ }
159335
+ if (newProperties.length === 0)
159336
+ return void 0;
159337
+ const modifiers = [];
159338
+ if ((_a = expandoFunc.modifiers) == null ? void 0 : _a.some((modifier) => modifier.kind === 95 /* ExportKeyword */)) {
159339
+ modifiers.push(factory.createModifier(95 /* ExportKeyword */));
159340
+ }
159341
+ modifiers.push(factory.createModifier(138 /* DeclareKeyword */));
159342
+ const namespace = factory.createModuleDeclaration(
159343
+ modifiers,
159344
+ expandoFunc.name,
159345
+ factory.createModuleBlock(newProperties),
159346
+ /*flags*/
159347
+ 32 /* Namespace */ | 128 /* ExportContext */ | 33554432 /* Ambient */ | 101441536 /* ContextFlags */
159348
+ );
159349
+ changeTracker.insertNodeAfter(sourceFile, expandoFunc, namespace);
159350
+ return [Diagnostics.Annotate_types_of_properties_expando_function_in_a_namespace];
159351
+ }
159352
+ function needsParenthesizedExpressionForAssertion(node) {
159353
+ return !isEntityNameExpression(node) && !isCallExpression(node) && !isObjectLiteralExpression(node) && !isArrayLiteralExpression(node);
159354
+ }
159355
+ function createAsExpression(node, type) {
159356
+ if (needsParenthesizedExpressionForAssertion(node)) {
159357
+ node = factory.createParenthesizedExpression(node);
159358
+ }
159359
+ return factory.createAsExpression(node, type);
159360
+ }
159361
+ function createSatisfiesAsExpression(node, type) {
159362
+ if (needsParenthesizedExpressionForAssertion(node)) {
159363
+ node = factory.createParenthesizedExpression(node);
159364
+ }
159365
+ return factory.createAsExpression(factory.createSatisfiesExpression(node, getSynthesizedDeepClone(type)), type);
159366
+ }
159367
+ function addInlineAssertion(span) {
159368
+ const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
159369
+ const expandoFunction = findExpandoFunction(nodeWithDiag);
159370
+ if (expandoFunction)
159371
+ return;
159372
+ const targetNode = findBestFittingNode(nodeWithDiag, span);
159373
+ if (!targetNode || isValueSignatureDeclaration(targetNode) || isValueSignatureDeclaration(targetNode.parent))
159374
+ return;
159375
+ const isExpressionTarget = isExpression(targetNode);
159376
+ const isShorthandPropertyAssignmentTarget = isShorthandPropertyAssignment(targetNode);
159377
+ if (!isShorthandPropertyAssignmentTarget && isDeclaration(targetNode)) {
159378
+ return void 0;
159379
+ }
159380
+ if (findAncestor(targetNode, isBindingPattern)) {
159381
+ return void 0;
159382
+ }
159383
+ if (findAncestor(targetNode, isEnumMember)) {
159384
+ return void 0;
159385
+ }
159386
+ if (isExpressionTarget && findAncestor(targetNode, isHeritageClause)) {
159387
+ return void 0;
159388
+ }
159389
+ if (isSpreadElement(targetNode)) {
159390
+ return void 0;
159391
+ }
159392
+ const variableDeclaration = findAncestor(targetNode, isVariableDeclaration);
159393
+ const type = variableDeclaration && typeChecker.getTypeAtLocation(variableDeclaration);
159394
+ if (type && type.flags & 8192 /* UniqueESSymbol */) {
159395
+ return void 0;
159396
+ }
159397
+ if (!(isExpressionTarget || isShorthandPropertyAssignmentTarget))
159398
+ return void 0;
159399
+ const { typeNode, mutatedTarget } = inferType(targetNode, type);
159400
+ if (!typeNode || mutatedTarget)
159401
+ return void 0;
159402
+ if (isShorthandPropertyAssignmentTarget) {
159403
+ changeTracker.insertNodeAt(
159404
+ sourceFile,
159405
+ targetNode.end,
159406
+ createAsExpression(
159407
+ getSynthesizedDeepClone(targetNode.name),
159408
+ typeNode
159409
+ ),
159410
+ {
159411
+ prefix: ": "
159412
+ }
159413
+ );
159414
+ } else if (isExpressionTarget) {
159415
+ changeTracker.replaceNode(
159416
+ sourceFile,
159417
+ targetNode,
159418
+ createSatisfiesAsExpression(
159419
+ getSynthesizedDeepClone(targetNode),
159420
+ typeNode
159421
+ )
159422
+ );
159423
+ } else {
159424
+ Debug.assertNever(targetNode);
159425
+ }
159426
+ return [Diagnostics.Add_satisfies_and_an_inline_type_assertion_with_0, typeToStringForDiag(typeNode)];
159427
+ }
159428
+ function extractAsVariable(span) {
159429
+ const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
159430
+ const targetNode = findBestFittingNode(nodeWithDiag, span);
159431
+ if (!targetNode || isValueSignatureDeclaration(targetNode) || isValueSignatureDeclaration(targetNode.parent))
159432
+ return;
159433
+ const isExpressionTarget = isExpression(targetNode);
159434
+ if (!isExpressionTarget)
159435
+ return;
159436
+ if (isArrayLiteralExpression(targetNode)) {
159437
+ changeTracker.replaceNode(
159438
+ sourceFile,
159439
+ targetNode,
159440
+ createAsExpression(targetNode, factory.createTypeReferenceNode("const"))
159441
+ );
159442
+ return [Diagnostics.Mark_array_literal_as_const];
159443
+ }
159444
+ const parentPropertyAssignment = findAncestor(targetNode, isPropertyAssignment);
159445
+ if (parentPropertyAssignment) {
159446
+ if (parentPropertyAssignment === targetNode.parent && isEntityNameExpression(targetNode))
159447
+ return;
159448
+ const tempName = factory.createUniqueName(
159449
+ getIdentifierForNode(targetNode, sourceFile, typeChecker, sourceFile),
159450
+ 16 /* Optimistic */
159451
+ );
159452
+ let replacementTarget = targetNode;
159453
+ let initializationNode = targetNode;
159454
+ if (isSpreadElement(replacementTarget)) {
159455
+ replacementTarget = walkUpParenthesizedExpressions(replacementTarget.parent);
159456
+ if (isConstAssertion2(replacementTarget.parent)) {
159457
+ initializationNode = replacementTarget = replacementTarget.parent;
159458
+ } else {
159459
+ initializationNode = createAsExpression(
159460
+ replacementTarget,
159461
+ factory.createTypeReferenceNode("const")
159462
+ );
159463
+ }
159464
+ }
159465
+ if (isEntityNameExpression(replacementTarget))
159466
+ return void 0;
159467
+ const variableDefinition = factory.createVariableStatement(
159468
+ /*modifiers*/
159469
+ void 0,
159470
+ factory.createVariableDeclarationList([
159471
+ factory.createVariableDeclaration(
159472
+ tempName,
159473
+ /*exclamationToken*/
159474
+ void 0,
159475
+ /*type*/
159476
+ void 0,
159477
+ initializationNode
159478
+ )
159479
+ ], 2 /* Const */)
159480
+ );
159481
+ const statement = findAncestor(targetNode, isStatement);
159482
+ changeTracker.insertNodeBefore(sourceFile, statement, variableDefinition);
159483
+ changeTracker.replaceNode(
159484
+ sourceFile,
159485
+ replacementTarget,
159486
+ factory.createAsExpression(
159487
+ factory.cloneNode(tempName),
159488
+ factory.createTypeQueryNode(
159489
+ factory.cloneNode(tempName)
159490
+ )
159491
+ )
159492
+ );
159493
+ return [Diagnostics.Extract_to_variable_and_replace_with_0_as_typeof_0, typeToStringForDiag(tempName)];
159494
+ }
159495
+ }
159496
+ function findExpandoFunction(node) {
159497
+ const expandoDeclaration = findAncestor(node, (n) => isStatement(n) ? "quit" : isExpandoPropertyDeclaration(n));
159498
+ if (expandoDeclaration && isExpandoPropertyDeclaration(expandoDeclaration)) {
159499
+ let assignmentTarget = expandoDeclaration;
159500
+ if (isBinaryExpression(assignmentTarget)) {
159501
+ assignmentTarget = assignmentTarget.left;
159502
+ if (!isExpandoPropertyDeclaration(assignmentTarget))
159503
+ return void 0;
159504
+ }
159505
+ const targetType = typeChecker.getTypeAtLocation(assignmentTarget.expression);
159506
+ if (!targetType)
159507
+ return;
159508
+ const properties = typeChecker.getPropertiesOfType(targetType);
159509
+ if (some(properties, (p) => p.valueDeclaration === expandoDeclaration || p.valueDeclaration === expandoDeclaration.parent)) {
159510
+ const fn = targetType.symbol.valueDeclaration;
159511
+ if (fn) {
159512
+ if (isFunctionExpressionOrArrowFunction(fn) && isVariableDeclaration(fn.parent)) {
159513
+ return fn.parent;
159514
+ }
159515
+ if (isFunctionDeclaration(fn)) {
159516
+ return fn;
159517
+ }
159518
+ }
159519
+ }
159520
+ }
159521
+ return void 0;
159522
+ }
159523
+ function fixIsolatedDeclarationError(node) {
159524
+ if (fixedNodes == null ? void 0 : fixedNodes.has(node))
159525
+ return void 0;
159526
+ fixedNodes == null ? void 0 : fixedNodes.add(node);
159527
+ switch (node.kind) {
159528
+ case 169 /* Parameter */:
159529
+ case 172 /* PropertyDeclaration */:
159530
+ case 260 /* VariableDeclaration */:
159531
+ return addTypeToVariableLike(node);
159532
+ case 219 /* ArrowFunction */:
159533
+ case 218 /* FunctionExpression */:
159534
+ case 262 /* FunctionDeclaration */:
159535
+ case 174 /* MethodDeclaration */:
159536
+ case 177 /* GetAccessor */:
159537
+ return addTypeToSignatureDeclaration(node, sourceFile);
159538
+ case 277 /* ExportAssignment */:
159539
+ return transformExportAssignment(node);
159540
+ case 263 /* ClassDeclaration */:
159541
+ return transformExtendsClauseWithExpression(node);
159542
+ case 206 /* ObjectBindingPattern */:
159543
+ case 207 /* ArrayBindingPattern */:
159544
+ return transformDestructuringPatterns(node);
159545
+ default:
159546
+ throw new Error(`Cannot find a fix for the given node ${node.kind}`);
159547
+ }
159548
+ }
159549
+ function addTypeToSignatureDeclaration(func, sourceFile2) {
159550
+ if (func.type) {
159551
+ return;
159552
+ }
159553
+ const { typeNode } = inferType(func);
159554
+ if (typeNode) {
159555
+ changeTracker.tryInsertTypeAnnotation(
159556
+ sourceFile2,
159557
+ func,
159558
+ typeNode
159559
+ );
159560
+ return [Diagnostics.Add_return_type_0, typeToStringForDiag(typeNode)];
159561
+ }
159562
+ }
159563
+ function transformExportAssignment(defaultExport) {
159564
+ if (defaultExport.isExportEquals) {
159565
+ return;
159566
+ }
159567
+ const { typeNode } = inferType(defaultExport.expression);
159568
+ if (!typeNode)
159569
+ return void 0;
159570
+ const defaultIdentifier = factory.createUniqueName("_default");
159571
+ changeTracker.replaceNodeWithNodes(sourceFile, defaultExport, [
159572
+ factory.createVariableStatement(
159573
+ /*modifiers*/
159574
+ void 0,
159575
+ factory.createVariableDeclarationList(
159576
+ [factory.createVariableDeclaration(
159577
+ defaultIdentifier,
159578
+ /*exclamationToken*/
159579
+ void 0,
159580
+ typeNode,
159581
+ defaultExport.expression
159582
+ )],
159583
+ 2 /* Const */
159584
+ )
159585
+ ),
159586
+ factory.updateExportAssignment(defaultExport, defaultExport == null ? void 0 : defaultExport.modifiers, defaultIdentifier)
159587
+ ]);
159588
+ return [
159589
+ Diagnostics.Extract_default_export_to_variable
159590
+ ];
159591
+ }
159592
+ function transformExtendsClauseWithExpression(classDecl) {
159593
+ var _a, _b;
159594
+ const extendsClause = (_a = classDecl.heritageClauses) == null ? void 0 : _a.find((p) => p.token === 96 /* ExtendsKeyword */);
159595
+ const heritageExpression = extendsClause == null ? void 0 : extendsClause.types[0];
159596
+ if (!heritageExpression) {
159597
+ return void 0;
159598
+ }
159599
+ const { typeNode: heritageTypeNode } = inferType(heritageExpression.expression);
159600
+ if (!heritageTypeNode) {
159601
+ return void 0;
159602
+ }
159603
+ const baseClassName = factory.createUniqueName(
159604
+ classDecl.name ? classDecl.name.text + "Base" : "Anonymous",
159605
+ 16 /* Optimistic */
159606
+ );
159607
+ const heritageVariable = factory.createVariableStatement(
159608
+ /*modifiers*/
159609
+ void 0,
159610
+ factory.createVariableDeclarationList(
159611
+ [factory.createVariableDeclaration(
159612
+ baseClassName,
159613
+ /*exclamationToken*/
159614
+ void 0,
159615
+ heritageTypeNode,
159616
+ heritageExpression.expression
159617
+ )],
159618
+ 2 /* Const */
159619
+ )
159620
+ );
159621
+ changeTracker.insertNodeBefore(sourceFile, classDecl, heritageVariable);
159622
+ const trailingComments = getTrailingCommentRanges(sourceFile.text, heritageExpression.end);
159623
+ const realEnd = ((_b = trailingComments == null ? void 0 : trailingComments[trailingComments.length - 1]) == null ? void 0 : _b.end) ?? heritageExpression.end;
159624
+ changeTracker.replaceRange(
159625
+ sourceFile,
159626
+ {
159627
+ pos: heritageExpression.getFullStart(),
159628
+ end: realEnd
159629
+ },
159630
+ baseClassName,
159631
+ {
159632
+ prefix: " "
159633
+ }
159634
+ );
159635
+ return [Diagnostics.Extract_base_class_to_variable];
159636
+ }
159637
+ let ExpressionType;
159638
+ ((ExpressionType2) => {
159639
+ ExpressionType2[ExpressionType2["Text"] = 0] = "Text";
159640
+ ExpressionType2[ExpressionType2["Computed"] = 1] = "Computed";
159641
+ ExpressionType2[ExpressionType2["ArrayAccess"] = 2] = "ArrayAccess";
159642
+ ExpressionType2[ExpressionType2["Identifier"] = 3] = "Identifier";
159643
+ })(ExpressionType || (ExpressionType = {}));
159644
+ function transformDestructuringPatterns(bindingPattern) {
159645
+ var _a;
159646
+ const enclosingVariableDeclaration = bindingPattern.parent;
159647
+ const enclosingVarStmt = bindingPattern.parent.parent.parent;
159648
+ if (!enclosingVariableDeclaration.initializer)
159649
+ return void 0;
159650
+ let baseExpr;
159651
+ const newNodes = [];
159652
+ if (!isIdentifier(enclosingVariableDeclaration.initializer)) {
159653
+ const tempHolderForReturn = factory.createUniqueName("dest", 16 /* Optimistic */);
159654
+ baseExpr = { expression: { kind: 3 /* Identifier */, identifier: tempHolderForReturn } };
159655
+ newNodes.push(factory.createVariableStatement(
159656
+ /*modifiers*/
159657
+ void 0,
159658
+ factory.createVariableDeclarationList(
159659
+ [factory.createVariableDeclaration(
159660
+ tempHolderForReturn,
159661
+ /*exclamationToken*/
159662
+ void 0,
159663
+ /*type*/
159664
+ void 0,
159665
+ enclosingVariableDeclaration.initializer
159666
+ )],
159667
+ 2 /* Const */
159668
+ )
159669
+ ));
159670
+ } else {
159671
+ baseExpr = { expression: { kind: 3 /* Identifier */, identifier: enclosingVariableDeclaration.initializer } };
159672
+ }
159673
+ const bindingElements = [];
159674
+ if (isArrayBindingPattern(bindingPattern)) {
159675
+ addArrayBindingPatterns(bindingPattern, bindingElements, baseExpr);
159676
+ } else {
159677
+ addObjectBindingPatterns(bindingPattern, bindingElements, baseExpr);
159678
+ }
159679
+ const expressionToVar = /* @__PURE__ */ new Map();
159680
+ for (const bindingElement of bindingElements) {
159681
+ if (bindingElement.element.propertyName && isComputedPropertyName(bindingElement.element.propertyName)) {
159682
+ const computedExpression = bindingElement.element.propertyName.expression;
159683
+ const identifierForComputedProperty = factory.getGeneratedNameForNode(computedExpression);
159684
+ const variableDecl = factory.createVariableDeclaration(
159685
+ identifierForComputedProperty,
159686
+ /*exclamationToken*/
159687
+ void 0,
159688
+ /*type*/
159689
+ void 0,
159690
+ computedExpression
159691
+ );
159692
+ const variableList = factory.createVariableDeclarationList([variableDecl], 2 /* Const */);
159693
+ const variableStatement = factory.createVariableStatement(
159694
+ /*modifiers*/
159695
+ void 0,
159696
+ variableList
159697
+ );
159698
+ newNodes.push(variableStatement);
159699
+ expressionToVar.set(computedExpression, identifierForComputedProperty);
159700
+ }
159701
+ const name = bindingElement.element.name;
159702
+ if (isArrayBindingPattern(name)) {
159703
+ addArrayBindingPatterns(name, bindingElements, bindingElement);
159704
+ } else if (isObjectBindingPattern(name)) {
159705
+ addObjectBindingPatterns(name, bindingElements, bindingElement);
159706
+ } else {
159707
+ const { typeNode } = inferType(name);
159708
+ let variableInitializer = createChainedExpression(bindingElement, expressionToVar);
159709
+ if (bindingElement.element.initializer) {
159710
+ const propertyName = (_a = bindingElement.element) == null ? void 0 : _a.propertyName;
159711
+ const tempName = factory.createUniqueName(
159712
+ propertyName && isIdentifier(propertyName) ? propertyName.text : "temp",
159713
+ 16 /* Optimistic */
159714
+ );
159715
+ newNodes.push(factory.createVariableStatement(
159716
+ /*modifiers*/
159717
+ void 0,
159718
+ factory.createVariableDeclarationList(
159719
+ [factory.createVariableDeclaration(
159720
+ tempName,
159721
+ /*exclamationToken*/
159722
+ void 0,
159723
+ /*type*/
159724
+ void 0,
159725
+ variableInitializer
159726
+ )],
159727
+ 2 /* Const */
159728
+ )
159729
+ ));
159730
+ variableInitializer = factory.createConditionalExpression(
159731
+ factory.createBinaryExpression(
159732
+ tempName,
159733
+ factory.createToken(37 /* EqualsEqualsEqualsToken */),
159734
+ factory.createIdentifier("undefined")
159735
+ ),
159736
+ factory.createToken(58 /* QuestionToken */),
159737
+ bindingElement.element.initializer,
159738
+ factory.createToken(59 /* ColonToken */),
159739
+ variableInitializer
159740
+ );
159741
+ }
159742
+ const exportModifier = hasSyntacticModifier(enclosingVarStmt, 32 /* Export */) ? [factory.createToken(95 /* ExportKeyword */)] : void 0;
159743
+ newNodes.push(factory.createVariableStatement(
159744
+ exportModifier,
159745
+ factory.createVariableDeclarationList(
159746
+ [factory.createVariableDeclaration(
159747
+ name,
159748
+ /*exclamationToken*/
159749
+ void 0,
159750
+ typeNode,
159751
+ variableInitializer
159752
+ )],
159753
+ 2 /* Const */
159754
+ )
159755
+ ));
159756
+ }
159757
+ }
159758
+ if (enclosingVarStmt.declarationList.declarations.length > 1) {
159759
+ newNodes.push(factory.updateVariableStatement(
159760
+ enclosingVarStmt,
159761
+ enclosingVarStmt.modifiers,
159762
+ factory.updateVariableDeclarationList(
159763
+ enclosingVarStmt.declarationList,
159764
+ enclosingVarStmt.declarationList.declarations.filter((node) => node !== bindingPattern.parent)
159765
+ )
159766
+ ));
159767
+ }
159768
+ changeTracker.replaceNodeWithNodes(sourceFile, enclosingVarStmt, newNodes);
159769
+ return [
159770
+ Diagnostics.Extract_binding_expressions_to_variable
159771
+ ];
159772
+ }
159773
+ function addArrayBindingPatterns(bindingPattern, bindingElements, parent2) {
159774
+ for (let i = 0; i < bindingPattern.elements.length; ++i) {
159775
+ const element = bindingPattern.elements[i];
159776
+ if (isOmittedExpression(element)) {
159777
+ continue;
159778
+ }
159779
+ bindingElements.push({
159780
+ element,
159781
+ parent: parent2,
159782
+ expression: { kind: 2 /* ArrayAccess */, arrayIndex: i }
159783
+ });
159784
+ }
159785
+ }
159786
+ function addObjectBindingPatterns(bindingPattern, bindingElements, parent2) {
159787
+ for (const bindingElement of bindingPattern.elements) {
159788
+ let name;
159789
+ if (bindingElement.propertyName) {
159790
+ if (isComputedPropertyName(bindingElement.propertyName)) {
159791
+ bindingElements.push({
159792
+ element: bindingElement,
159793
+ parent: parent2,
159794
+ expression: { kind: 1 /* Computed */, computed: bindingElement.propertyName.expression }
159795
+ });
159796
+ continue;
159797
+ } else {
159798
+ name = bindingElement.propertyName.text;
159799
+ }
159800
+ } else {
159801
+ name = bindingElement.name.text;
159802
+ }
159803
+ bindingElements.push({
159804
+ element: bindingElement,
159805
+ parent: parent2,
159806
+ expression: { kind: 0 /* Text */, text: name }
159807
+ });
159808
+ }
159809
+ }
159810
+ function createChainedExpression(expression, expressionToVar) {
159811
+ const reverseTraverse = [expression];
159812
+ while (expression.parent) {
159813
+ expression = expression.parent;
159814
+ reverseTraverse.push(expression);
159815
+ }
159816
+ let chainedExpression = reverseTraverse[reverseTraverse.length - 1].expression.identifier;
159817
+ for (let i = reverseTraverse.length - 2; i >= 0; --i) {
159818
+ const nextSubExpr = reverseTraverse[i].expression;
159819
+ if (nextSubExpr.kind === 0 /* Text */) {
159820
+ chainedExpression = factory.createPropertyAccessChain(
159821
+ chainedExpression,
159822
+ /*questionDotToken*/
159823
+ void 0,
159824
+ factory.createIdentifier(nextSubExpr.text)
159825
+ );
159826
+ } else if (nextSubExpr.kind === 1 /* Computed */) {
159827
+ chainedExpression = factory.createElementAccessExpression(
159828
+ chainedExpression,
159829
+ expressionToVar.get(nextSubExpr.computed)
159830
+ );
159831
+ } else if (nextSubExpr.kind === 2 /* ArrayAccess */) {
159832
+ chainedExpression = factory.createElementAccessExpression(
159833
+ chainedExpression,
159834
+ nextSubExpr.arrayIndex
159835
+ );
159836
+ }
159837
+ }
159838
+ return chainedExpression;
159839
+ }
159840
+ function inferType(node, variableType) {
159841
+ if (typePrintMode === 1 /* Relative */) {
159842
+ return relativeType(node);
159843
+ }
159844
+ let type = isValueSignatureDeclaration(node) ? tryGetReturnType2(node) : typeChecker.getTypeAtLocation(node);
159845
+ if (!type) {
159846
+ return emptyInferenceResult;
159847
+ }
159848
+ if (typePrintMode === 2 /* Widened */) {
159849
+ if (variableType) {
159850
+ type = variableType;
159851
+ }
159852
+ const widenedType = typeChecker.getWidenedLiteralType(type);
159853
+ if (typeChecker.isTypeAssignableTo(widenedType, type)) {
159854
+ return emptyInferenceResult;
159855
+ }
159856
+ type = widenedType;
159857
+ }
159858
+ if (isParameter(node) && emitResolver.requiresAddingImplicitUndefined(node)) {
159859
+ type = typeChecker.getUnionType([typeChecker.getUndefinedType(), type], 0 /* None */);
159860
+ }
159861
+ const flags = (isVariableDeclaration(node) || isPropertyDeclaration(node) && hasSyntacticModifier(node, 256 /* Static */ | 8 /* Readonly */)) && type.flags & 8192 /* UniqueESSymbol */ ? 1048576 /* AllowUniqueESSymbolType */ : 0 /* None */;
159862
+ return {
159863
+ typeNode: typeToTypeNode2(type, findAncestor(node, isDeclaration) ?? sourceFile, flags),
159864
+ mutatedTarget: false
159865
+ };
159866
+ }
159867
+ function createTypeOfFromEntityNameExpression(node) {
159868
+ return factory.createTypeQueryNode(getSynthesizedDeepClone(node));
159869
+ }
159870
+ function typeFromArraySpreadElements(node, name = "temp") {
159871
+ const isConstContext = !!findAncestor(node, isConstAssertion2);
159872
+ if (!isConstContext)
159873
+ return emptyInferenceResult;
159874
+ return typeFromSpreads(
159875
+ node,
159876
+ name,
159877
+ isConstContext,
159878
+ (n) => n.elements,
159879
+ isSpreadElement,
159880
+ factory.createSpreadElement,
159881
+ (props) => factory.createArrayLiteralExpression(
159882
+ props,
159883
+ /*multiLine*/
159884
+ true
159885
+ ),
159886
+ (types) => factory.createTupleTypeNode(types.map(factory.createRestTypeNode))
159887
+ );
159888
+ }
159889
+ function typeFromObjectSpreadAssignment(node, name = "temp") {
159890
+ const isConstContext = !!findAncestor(node, isConstAssertion2);
159891
+ return typeFromSpreads(
159892
+ node,
159893
+ name,
159894
+ isConstContext,
159895
+ (n) => n.properties,
159896
+ isSpreadAssignment,
159897
+ factory.createSpreadAssignment,
159898
+ (props) => factory.createObjectLiteralExpression(
159899
+ props,
159900
+ /*multiLine*/
159901
+ true
159902
+ ),
159903
+ factory.createIntersectionTypeNode
159904
+ );
159905
+ }
159906
+ function typeFromSpreads(node, name, isConstContext, getChildren, isSpread, createSpread, makeNodeOfKind, finalType) {
159907
+ const intersectionTypes = [];
159908
+ const newSpreads = [];
159909
+ let currentVariableProperties;
159910
+ const statement = findAncestor(node, isStatement);
159911
+ for (const prop of getChildren(node)) {
159912
+ if (isSpread(prop)) {
159913
+ finalizesVariablePart();
159914
+ if (isEntityNameExpression(prop.expression)) {
159915
+ intersectionTypes.push(createTypeOfFromEntityNameExpression(prop.expression));
159916
+ newSpreads.push(prop);
159917
+ } else {
159918
+ makeVariable(prop.expression);
159919
+ }
159920
+ } else {
159921
+ (currentVariableProperties ?? (currentVariableProperties = [])).push(prop);
159922
+ }
159923
+ }
159924
+ if (newSpreads.length === 0) {
159925
+ return emptyInferenceResult;
159926
+ }
159927
+ finalizesVariablePart();
159928
+ changeTracker.replaceNode(sourceFile, node, makeNodeOfKind(newSpreads));
159929
+ return {
159930
+ typeNode: finalType(intersectionTypes),
159931
+ mutatedTarget: true
159932
+ };
159933
+ function makeVariable(expression) {
159934
+ const tempName = factory.createUniqueName(
159935
+ name + "_Part" + (newSpreads.length + 1),
159936
+ 16 /* Optimistic */
159937
+ );
159938
+ const initializer = !isConstContext ? expression : factory.createAsExpression(
159939
+ expression,
159940
+ factory.createTypeReferenceNode("const")
159941
+ );
159942
+ const variableDefinition = factory.createVariableStatement(
159943
+ /*modifiers*/
159944
+ void 0,
159945
+ factory.createVariableDeclarationList([
159946
+ factory.createVariableDeclaration(
159947
+ tempName,
159948
+ /*exclamationToken*/
159949
+ void 0,
159950
+ /*type*/
159951
+ void 0,
159952
+ initializer
159953
+ )
159954
+ ], 2 /* Const */)
159955
+ );
159956
+ changeTracker.insertNodeBefore(sourceFile, statement, variableDefinition);
159957
+ intersectionTypes.push(createTypeOfFromEntityNameExpression(tempName));
159958
+ newSpreads.push(createSpread(tempName));
159959
+ }
159960
+ function finalizesVariablePart() {
159961
+ if (currentVariableProperties) {
159962
+ makeVariable(makeNodeOfKind(
159963
+ currentVariableProperties
159964
+ ));
159965
+ currentVariableProperties = void 0;
159966
+ }
159967
+ }
159968
+ }
159969
+ function isConstAssertion2(location) {
159970
+ return isAssertionExpression(location) && isConstTypeReference(location.type);
159971
+ }
159972
+ function relativeType(node) {
159973
+ if (isParameter(node)) {
159974
+ return emptyInferenceResult;
159975
+ }
159976
+ if (isShorthandPropertyAssignment(node)) {
159977
+ return {
159978
+ typeNode: createTypeOfFromEntityNameExpression(node.name),
159979
+ mutatedTarget: false
159980
+ };
159981
+ }
159982
+ if (isEntityNameExpression(node)) {
159983
+ return {
159984
+ typeNode: createTypeOfFromEntityNameExpression(node),
159985
+ mutatedTarget: false
159986
+ };
159987
+ }
159988
+ if (isConstAssertion2(node)) {
159989
+ return relativeType(node.expression);
159990
+ }
159991
+ if (isArrayLiteralExpression(node)) {
159992
+ const variableDecl = findAncestor(node, isVariableDeclaration);
159993
+ const partName = variableDecl && isIdentifier(variableDecl.name) ? variableDecl.name.text : void 0;
159994
+ return typeFromArraySpreadElements(node, partName);
159995
+ }
159996
+ if (isObjectLiteralExpression(node)) {
159997
+ const variableDecl = findAncestor(node, isVariableDeclaration);
159998
+ const partName = variableDecl && isIdentifier(variableDecl.name) ? variableDecl.name.text : void 0;
159999
+ return typeFromObjectSpreadAssignment(node, partName);
160000
+ }
160001
+ if (isVariableDeclaration(node) && node.initializer) {
160002
+ return relativeType(node.initializer);
160003
+ }
160004
+ if (isConditionalExpression(node)) {
160005
+ const { typeNode: trueType, mutatedTarget: mTrue } = relativeType(node.whenTrue);
160006
+ if (!trueType)
160007
+ return emptyInferenceResult;
160008
+ const { typeNode: falseType, mutatedTarget: mFalse } = relativeType(node.whenFalse);
160009
+ if (!falseType)
160010
+ return emptyInferenceResult;
160011
+ return {
160012
+ typeNode: factory.createUnionTypeNode([trueType, falseType]),
160013
+ mutatedTarget: mTrue || mFalse
160014
+ };
160015
+ }
160016
+ return emptyInferenceResult;
160017
+ }
160018
+ function typeToTypeNode2(type, enclosingDeclaration, flags = 0 /* None */) {
160019
+ let isTruncated = false;
160020
+ const result2 = typeToAutoImportableTypeNode(typeChecker, importAdder, type, enclosingDeclaration, scriptTarget, declarationEmitNodeBuilderFlags2 | flags, {
160021
+ moduleResolverHost: program,
160022
+ trackSymbol() {
160023
+ return true;
160024
+ },
160025
+ reportTruncationError() {
160026
+ isTruncated = true;
160027
+ }
160028
+ });
160029
+ return isTruncated ? factory.createKeywordTypeNode(133 /* AnyKeyword */) : result2;
160030
+ }
160031
+ function tryGetReturnType2(node) {
160032
+ const signature = typeChecker.getSignatureFromDeclaration(node);
160033
+ if (signature) {
160034
+ return typeChecker.getReturnTypeOfSignature(signature);
160035
+ }
160036
+ }
160037
+ function addTypeToVariableLike(decl) {
160038
+ const { typeNode } = inferType(decl);
160039
+ if (typeNode) {
160040
+ if (decl.type) {
160041
+ changeTracker.replaceNode(getSourceFileOfNode(decl), decl.type, typeNode);
160042
+ } else {
160043
+ changeTracker.tryInsertTypeAnnotation(getSourceFileOfNode(decl), decl, typeNode);
160044
+ }
160045
+ return [Diagnostics.Add_annotation_of_type_0, typeToStringForDiag(typeNode)];
160046
+ }
160047
+ }
160048
+ function typeToStringForDiag(node) {
160049
+ setEmitFlags(node, 1 /* SingleLine */);
160050
+ const result2 = typePrinter.printNode(4 /* Unspecified */, node, sourceFile);
160051
+ if (result2.length > defaultMaximumTruncationLength) {
160052
+ return result2.substring(0, defaultMaximumTruncationLength - "...".length) + "...";
160053
+ }
160054
+ setEmitFlags(node, 0 /* None */);
160055
+ return result2;
160056
+ }
160057
+ }
160058
+ function findAncestorWithMissingType(node) {
160059
+ return findAncestor(node, (n) => {
160060
+ return canHaveTypeAnnotation.has(n.kind) && (!isObjectBindingPattern(n) && !isArrayBindingPattern(n) || isVariableDeclaration(n.parent));
160061
+ });
160062
+ }
160063
+ function findBestFittingNode(node, span) {
160064
+ while (node && node.end < span.start + span.length) {
160065
+ node = node.parent;
160066
+ }
160067
+ while (node.parent.pos === node.pos && node.parent.end === node.end) {
160068
+ node = node.parent;
160069
+ }
160070
+ if (isIdentifier(node) && hasInitializer(node.parent) && node.parent.initializer) {
160071
+ return node.parent.initializer;
160072
+ }
160073
+ return node;
160074
+ }
160075
+
160076
+ // src/services/codefixes/fixAwaitInSyncFunction.ts
160077
+ var fixId37 = "fixAwaitInSyncFunction";
160078
+ var errorCodes48 = [
159151
160079
  Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
159152
160080
  Diagnostics.await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
159153
160081
  Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
159154
160082
  Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
159155
160083
  ];
159156
160084
  registerCodeFix({
159157
- errorCodes: errorCodes47,
160085
+ errorCodes: errorCodes48,
159158
160086
  getCodeActions(context) {
159159
160087
  const { sourceFile, span } = context;
159160
160088
  const nodes = getNodes3(sourceFile, span.start);
159161
160089
  if (!nodes)
159162
160090
  return void 0;
159163
160091
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange31(t, sourceFile, nodes));
159164
- return [createCodeFixAction(fixId36, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId36, Diagnostics.Add_all_missing_async_modifiers)];
160092
+ return [createCodeFixAction(fixId37, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId37, Diagnostics.Add_all_missing_async_modifiers)];
159165
160093
  },
159166
- fixIds: [fixId36],
160094
+ fixIds: [fixId37],
159167
160095
  getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
159168
160096
  const seen = /* @__PURE__ */ new Map();
159169
- return codeFixAll(context, errorCodes47, (changes, diag2) => {
160097
+ return codeFixAll(context, errorCodes48, (changes, diag2) => {
159170
160098
  const nodes = getNodes3(diag2.file, diag2.start);
159171
160099
  if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore)))
159172
160100
  return;
@@ -159220,21 +160148,21 @@ function doChange31(changes, sourceFile, { insertBefore, returnType }) {
159220
160148
  }
159221
160149
 
159222
160150
  // src/services/codefixes/fixPropertyOverrideAccessor.ts
159223
- var errorCodes48 = [
160151
+ var errorCodes49 = [
159224
160152
  Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code,
159225
160153
  Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code
159226
160154
  ];
159227
- var fixId37 = "fixPropertyOverrideAccessor";
160155
+ var fixId38 = "fixPropertyOverrideAccessor";
159228
160156
  registerCodeFix({
159229
- errorCodes: errorCodes48,
160157
+ errorCodes: errorCodes49,
159230
160158
  getCodeActions(context) {
159231
160159
  const edits = doChange32(context.sourceFile, context.span.start, context.span.length, context.errorCode, context);
159232
160160
  if (edits) {
159233
- return [createCodeFixAction(fixId37, edits, Diagnostics.Generate_get_and_set_accessors, fixId37, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
160161
+ return [createCodeFixAction(fixId38, edits, Diagnostics.Generate_get_and_set_accessors, fixId38, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
159234
160162
  }
159235
160163
  },
159236
- fixIds: [fixId37],
159237
- getAllCodeActions: (context) => codeFixAll(context, errorCodes48, (changes, diag2) => {
160164
+ fixIds: [fixId38],
160165
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes49, (changes, diag2) => {
159238
160166
  const edits = doChange32(diag2.file, diag2.start, diag2.length, diag2.code, context);
159239
160167
  if (edits) {
159240
160168
  for (const edit of edits) {
@@ -159272,8 +160200,8 @@ function doChange32(file, start, length2, code, context) {
159272
160200
  }
159273
160201
 
159274
160202
  // src/services/codefixes/inferFromUsage.ts
159275
- var fixId38 = "inferFromUsage";
159276
- var errorCodes49 = [
160203
+ var fixId39 = "inferFromUsage";
160204
+ var errorCodes50 = [
159277
160205
  // Variable declarations
159278
160206
  Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
159279
160207
  // Variable uses
@@ -159307,7 +160235,7 @@ var errorCodes49 = [
159307
160235
  Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code
159308
160236
  ];
159309
160237
  registerCodeFix({
159310
- errorCodes: errorCodes49,
160238
+ errorCodes: errorCodes50,
159311
160239
  getCodeActions(context) {
159312
160240
  const { sourceFile, program, span: { start }, errorCode, cancellationToken, host, preferences } = context;
159313
160241
  const token = getTokenAtPosition(sourceFile, start);
@@ -159327,13 +160255,13 @@ registerCodeFix({
159327
160255
  );
159328
160256
  });
159329
160257
  const name = declaration && getNameOfDeclaration(declaration);
159330
- return !name || changes.length === 0 ? void 0 : [createCodeFixAction(fixId38, changes, [getDiagnostic(errorCode, token), getTextOfNode(name)], fixId38, Diagnostics.Infer_all_types_from_usage)];
160258
+ return !name || changes.length === 0 ? void 0 : [createCodeFixAction(fixId39, changes, [getDiagnostic(errorCode, token), getTextOfNode(name)], fixId39, Diagnostics.Infer_all_types_from_usage)];
159331
160259
  },
159332
- fixIds: [fixId38],
160260
+ fixIds: [fixId39],
159333
160261
  getAllCodeActions(context) {
159334
160262
  const { sourceFile, program, cancellationToken, host, preferences } = context;
159335
160263
  const markSeen = nodeSeenTracker();
159336
- return codeFixAll(context, errorCodes49, (changes, err) => {
160264
+ return codeFixAll(context, errorCodes50, (changes, err) => {
159337
160265
  doChange33(changes, sourceFile, getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
159338
160266
  });
159339
160267
  }
@@ -160272,13 +161200,13 @@ function inferTypeFromReferences(program, references, cancellationToken) {
160272
161200
  }
160273
161201
 
160274
161202
  // src/services/codefixes/fixReturnTypeInAsyncFunction.ts
160275
- var fixId39 = "fixReturnTypeInAsyncFunction";
160276
- var errorCodes50 = [
161203
+ var fixId40 = "fixReturnTypeInAsyncFunction";
161204
+ var errorCodes51 = [
160277
161205
  Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0.code
160278
161206
  ];
160279
161207
  registerCodeFix({
160280
- errorCodes: errorCodes50,
160281
- fixIds: [fixId39],
161208
+ errorCodes: errorCodes51,
161209
+ fixIds: [fixId40],
160282
161210
  getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
160283
161211
  const { sourceFile, program, span } = context;
160284
161212
  const checker = program.getTypeChecker();
@@ -160289,14 +161217,14 @@ registerCodeFix({
160289
161217
  const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
160290
161218
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange34(t, sourceFile, returnTypeNode, promisedTypeNode));
160291
161219
  return [createCodeFixAction(
160292
- fixId39,
161220
+ fixId40,
160293
161221
  changes,
160294
161222
  [Diagnostics.Replace_0_with_Promise_1, checker.typeToString(returnType), checker.typeToString(promisedType)],
160295
- fixId39,
161223
+ fixId40,
160296
161224
  Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions
160297
161225
  )];
160298
161226
  },
160299
- getAllCodeActions: (context) => codeFixAll(context, errorCodes50, (changes, diag2) => {
161227
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes51, (changes, diag2) => {
160300
161228
  const info = getInfo16(diag2.file, context.program.getTypeChecker(), diag2.start);
160301
161229
  if (info) {
160302
161230
  doChange34(changes, diag2.file, info.returnTypeNode, info.promisedTypeNode);
@@ -160332,13 +161260,13 @@ function doChange34(changes, sourceFile, returnTypeNode, promisedTypeNode) {
160332
161260
 
160333
161261
  // src/services/codefixes/disableJsDiagnostics.ts
160334
161262
  var fixName4 = "disableJsDiagnostics";
160335
- var fixId40 = "disableJsDiagnostics";
160336
- var errorCodes51 = mapDefined(Object.keys(Diagnostics), (key) => {
161263
+ var fixId41 = "disableJsDiagnostics";
161264
+ var errorCodes52 = mapDefined(Object.keys(Diagnostics), (key) => {
160337
161265
  const diag2 = Diagnostics[key];
160338
161266
  return diag2.category === 1 /* Error */ ? diag2.code : void 0;
160339
161267
  });
160340
161268
  registerCodeFix({
160341
- errorCodes: errorCodes51,
161269
+ errorCodes: errorCodes52,
160342
161270
  getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
160343
161271
  const { sourceFile, program, span, host, formatContext } = context;
160344
161272
  if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
@@ -160359,14 +161287,14 @@ registerCodeFix({
160359
161287
  )
160360
161288
  ];
160361
161289
  if (ts_textChanges_exports.isValidLocationToAddComment(sourceFile, span.start)) {
160362
- fixes.unshift(createCodeFixAction(fixName4, ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange8(t, sourceFile, span.start)), Diagnostics.Ignore_this_error_message, fixId40, Diagnostics.Add_ts_ignore_to_all_error_messages));
161290
+ fixes.unshift(createCodeFixAction(fixName4, ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange8(t, sourceFile, span.start)), Diagnostics.Ignore_this_error_message, fixId41, Diagnostics.Add_ts_ignore_to_all_error_messages));
160363
161291
  }
160364
161292
  return fixes;
160365
161293
  },
160366
- fixIds: [fixId40],
161294
+ fixIds: [fixId41],
160367
161295
  getAllCodeActions: (context) => {
160368
161296
  const seenLines = /* @__PURE__ */ new Set();
160369
- return codeFixAll(context, errorCodes51, (changes, diag2) => {
161297
+ return codeFixAll(context, errorCodes52, (changes, diag2) => {
160370
161298
  if (ts_textChanges_exports.isValidLocationToAddComment(diag2.file, diag2.start)) {
160371
161299
  makeChange8(changes, diag2.file, diag2.start, seenLines);
160372
161300
  }
@@ -161365,9 +162293,9 @@ var fixName6 = "strictClassInitialization";
161365
162293
  var fixIdAddDefiniteAssignmentAssertions = "addMissingPropertyDefiniteAssignmentAssertions";
161366
162294
  var fixIdAddUndefinedType = "addMissingPropertyUndefinedType";
161367
162295
  var fixIdAddInitializer = "addMissingPropertyInitializer";
161368
- var errorCodes52 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
162296
+ var errorCodes53 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
161369
162297
  registerCodeFix({
161370
- errorCodes: errorCodes52,
162298
+ errorCodes: errorCodes53,
161371
162299
  getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
161372
162300
  const info = getInfo17(context.sourceFile, context.span.start);
161373
162301
  if (!info)
@@ -161380,7 +162308,7 @@ registerCodeFix({
161380
162308
  },
161381
162309
  fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
161382
162310
  getAllCodeActions: (context) => {
161383
- return codeFixAll(context, errorCodes52, (changes, diag2) => {
162311
+ return codeFixAll(context, errorCodes53, (changes, diag2) => {
161384
162312
  const info = getInfo17(diag2.file, diag2.start);
161385
162313
  if (!info)
161386
162314
  return;
@@ -161510,20 +162438,20 @@ function getDefaultValueFromType(checker, type) {
161510
162438
  }
161511
162439
 
161512
162440
  // src/services/codefixes/requireInTs.ts
161513
- var fixId41 = "requireInTs";
161514
- var errorCodes53 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
162441
+ var fixId42 = "requireInTs";
162442
+ var errorCodes54 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
161515
162443
  registerCodeFix({
161516
- errorCodes: errorCodes53,
162444
+ errorCodes: errorCodes54,
161517
162445
  getCodeActions(context) {
161518
162446
  const info = getInfo18(context.sourceFile, context.program, context.span.start);
161519
162447
  if (!info) {
161520
162448
  return void 0;
161521
162449
  }
161522
162450
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange35(t, context.sourceFile, info));
161523
- return [createCodeFixAction(fixId41, changes, Diagnostics.Convert_require_to_import, fixId41, Diagnostics.Convert_all_require_to_import)];
162451
+ return [createCodeFixAction(fixId42, changes, Diagnostics.Convert_require_to_import, fixId42, Diagnostics.Convert_all_require_to_import)];
161524
162452
  },
161525
- fixIds: [fixId41],
161526
- getAllCodeActions: (context) => codeFixAll(context, errorCodes53, (changes, diag2) => {
162453
+ fixIds: [fixId42],
162454
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes54, (changes, diag2) => {
161527
162455
  const info = getInfo18(diag2.file, context.program, diag2.start);
161528
162456
  if (info) {
161529
162457
  doChange35(changes, context.sourceFile, info);
@@ -161598,20 +162526,20 @@ function tryCreateNamedImportsFromObjectBindingPattern(node) {
161598
162526
  }
161599
162527
 
161600
162528
  // src/services/codefixes/useDefaultImport.ts
161601
- var fixId42 = "useDefaultImport";
161602
- var errorCodes54 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
162529
+ var fixId43 = "useDefaultImport";
162530
+ var errorCodes55 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
161603
162531
  registerCodeFix({
161604
- errorCodes: errorCodes54,
162532
+ errorCodes: errorCodes55,
161605
162533
  getCodeActions(context) {
161606
162534
  const { sourceFile, span: { start } } = context;
161607
162535
  const info = getInfo19(sourceFile, start);
161608
162536
  if (!info)
161609
162537
  return void 0;
161610
162538
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange36(t, sourceFile, info, context.preferences));
161611
- return [createCodeFixAction(fixId42, changes, Diagnostics.Convert_to_default_import, fixId42, Diagnostics.Convert_all_to_default_imports)];
162539
+ return [createCodeFixAction(fixId43, changes, Diagnostics.Convert_to_default_import, fixId43, Diagnostics.Convert_all_to_default_imports)];
161612
162540
  },
161613
- fixIds: [fixId42],
161614
- getAllCodeActions: (context) => codeFixAll(context, errorCodes54, (changes, diag2) => {
162541
+ fixIds: [fixId43],
162542
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes55, (changes, diag2) => {
161615
162543
  const info = getInfo19(diag2.file, diag2.start);
161616
162544
  if (info)
161617
162545
  doChange36(changes, diag2.file, info, context.preferences);
@@ -161640,21 +162568,21 @@ function doChange36(changes, sourceFile, info, preferences) {
161640
162568
  }
161641
162569
 
161642
162570
  // src/services/codefixes/useBigintLiteral.ts
161643
- var fixId43 = "useBigintLiteral";
161644
- var errorCodes55 = [
162571
+ var fixId44 = "useBigintLiteral";
162572
+ var errorCodes56 = [
161645
162573
  Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code
161646
162574
  ];
161647
162575
  registerCodeFix({
161648
- errorCodes: errorCodes55,
162576
+ errorCodes: errorCodes56,
161649
162577
  getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
161650
162578
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange9(t, context.sourceFile, context.span));
161651
162579
  if (changes.length > 0) {
161652
- return [createCodeFixAction(fixId43, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId43, Diagnostics.Convert_all_to_bigint_numeric_literals)];
162580
+ return [createCodeFixAction(fixId44, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId44, Diagnostics.Convert_all_to_bigint_numeric_literals)];
161653
162581
  }
161654
162582
  },
161655
- fixIds: [fixId43],
162583
+ fixIds: [fixId44],
161656
162584
  getAllCodeActions: (context) => {
161657
- return codeFixAll(context, errorCodes55, (changes, diag2) => makeChange9(changes, diag2.file, diag2));
162585
+ return codeFixAll(context, errorCodes56, (changes, diag2) => makeChange9(changes, diag2.file, diag2));
161658
162586
  }
161659
162587
  });
161660
162588
  function makeChange9(changeTracker, sourceFile, span) {
@@ -161668,18 +162596,18 @@ function makeChange9(changeTracker, sourceFile, span) {
161668
162596
 
161669
162597
  // src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts
161670
162598
  var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
161671
- var fixId44 = fixIdAddMissingTypeof;
161672
- var errorCodes56 = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
162599
+ var fixId45 = fixIdAddMissingTypeof;
162600
+ var errorCodes57 = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
161673
162601
  registerCodeFix({
161674
- errorCodes: errorCodes56,
162602
+ errorCodes: errorCodes57,
161675
162603
  getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
161676
162604
  const { sourceFile, span } = context;
161677
162605
  const importType = getImportTypeNode(sourceFile, span.start);
161678
162606
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange37(t, sourceFile, importType));
161679
- return [createCodeFixAction(fixId44, changes, Diagnostics.Add_missing_typeof, fixId44, Diagnostics.Add_missing_typeof)];
162607
+ return [createCodeFixAction(fixId45, changes, Diagnostics.Add_missing_typeof, fixId45, Diagnostics.Add_missing_typeof)];
161680
162608
  },
161681
- fixIds: [fixId44],
161682
- getAllCodeActions: (context) => codeFixAll(context, errorCodes56, (changes, diag2) => doChange37(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
162609
+ fixIds: [fixId45],
162610
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes57, (changes, diag2) => doChange37(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
161683
162611
  });
161684
162612
  function getImportTypeNode(sourceFile, pos) {
161685
162613
  const token = getTokenAtPosition(sourceFile, pos);
@@ -161702,9 +162630,9 @@ function doChange37(changes, sourceFile, importType) {
161702
162630
 
161703
162631
  // src/services/codefixes/wrapJsxInFragment.ts
161704
162632
  var fixID2 = "wrapJsxInFragment";
161705
- var errorCodes57 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
162633
+ var errorCodes58 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
161706
162634
  registerCodeFix({
161707
- errorCodes: errorCodes57,
162635
+ errorCodes: errorCodes58,
161708
162636
  getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
161709
162637
  const { sourceFile, span } = context;
161710
162638
  const node = findNodeToFix(sourceFile, span.start);
@@ -161714,7 +162642,7 @@ registerCodeFix({
161714
162642
  return [createCodeFixAction(fixID2, changes, Diagnostics.Wrap_in_JSX_fragment, fixID2, Diagnostics.Wrap_all_unparented_JSX_in_JSX_fragment)];
161715
162643
  },
161716
162644
  fixIds: [fixID2],
161717
- getAllCodeActions: (context) => codeFixAll(context, errorCodes57, (changes, diag2) => {
162645
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes58, (changes, diag2) => {
161718
162646
  const node = findNodeToFix(context.sourceFile, diag2.start);
161719
162647
  if (!node)
161720
162648
  return void 0;
@@ -161759,16 +162687,16 @@ function flattenInvalidBinaryExpr(node) {
161759
162687
  }
161760
162688
 
161761
162689
  // src/services/codefixes/wrapDecoratorInParentheses.ts
161762
- var fixId45 = "wrapDecoratorInParentheses";
161763
- var errorCodes58 = [Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator.code];
162690
+ var fixId46 = "wrapDecoratorInParentheses";
162691
+ var errorCodes59 = [Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator.code];
161764
162692
  registerCodeFix({
161765
- errorCodes: errorCodes58,
162693
+ errorCodes: errorCodes59,
161766
162694
  getCodeActions: function getCodeActionsToWrapDecoratorExpressionInParentheses(context) {
161767
162695
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span.start));
161768
- return [createCodeFixAction(fixId45, changes, Diagnostics.Wrap_in_parentheses, fixId45, Diagnostics.Wrap_all_invalid_decorator_expressions_in_parentheses)];
162696
+ return [createCodeFixAction(fixId46, changes, Diagnostics.Wrap_in_parentheses, fixId46, Diagnostics.Wrap_all_invalid_decorator_expressions_in_parentheses)];
161769
162697
  },
161770
- fixIds: [fixId45],
161771
- getAllCodeActions: (context) => codeFixAll(context, errorCodes58, (changes, diag2) => makeChange10(changes, diag2.file, diag2.start))
162698
+ fixIds: [fixId46],
162699
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes59, (changes, diag2) => makeChange10(changes, diag2.file, diag2.start))
161772
162700
  });
161773
162701
  function makeChange10(changeTracker, sourceFile, pos) {
161774
162702
  const token = getTokenAtPosition(sourceFile, pos);
@@ -161779,10 +162707,10 @@ function makeChange10(changeTracker, sourceFile, pos) {
161779
162707
  }
161780
162708
 
161781
162709
  // src/services/codefixes/convertToMappedObjectType.ts
161782
- var fixId46 = "fixConvertToMappedObjectType";
161783
- var errorCodes59 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
162710
+ var fixId47 = "fixConvertToMappedObjectType";
162711
+ var errorCodes60 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
161784
162712
  registerCodeFix({
161785
- errorCodes: errorCodes59,
162713
+ errorCodes: errorCodes60,
161786
162714
  getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
161787
162715
  const { sourceFile, span } = context;
161788
162716
  const info = getInfo20(sourceFile, span.start);
@@ -161790,10 +162718,10 @@ registerCodeFix({
161790
162718
  return void 0;
161791
162719
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(t, sourceFile, info));
161792
162720
  const name = idText(info.container.name);
161793
- return [createCodeFixAction(fixId46, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId46, [Diagnostics.Convert_0_to_mapped_object_type, name])];
162721
+ return [createCodeFixAction(fixId47, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId47, [Diagnostics.Convert_0_to_mapped_object_type, name])];
161794
162722
  },
161795
- fixIds: [fixId46],
161796
- getAllCodeActions: (context) => codeFixAll(context, errorCodes59, (changes, diag2) => {
162723
+ fixIds: [fixId47],
162724
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes60, (changes, diag2) => {
161797
162725
  const info = getInfo20(diag2.file, diag2.start);
161798
162726
  if (info)
161799
162727
  doChange39(changes, diag2.file, info);
@@ -161841,12 +162769,12 @@ function doChange39(changes, sourceFile, { indexSignature, container }) {
161841
162769
  }
161842
162770
 
161843
162771
  // src/services/codefixes/removeAccidentalCallParentheses.ts
161844
- var fixId47 = "removeAccidentalCallParentheses";
161845
- var errorCodes60 = [
162772
+ var fixId48 = "removeAccidentalCallParentheses";
162773
+ var errorCodes61 = [
161846
162774
  Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
161847
162775
  ];
161848
162776
  registerCodeFix({
161849
- errorCodes: errorCodes60,
162777
+ errorCodes: errorCodes61,
161850
162778
  getCodeActions(context) {
161851
162779
  const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
161852
162780
  if (!callExpression) {
@@ -161855,27 +162783,27 @@ registerCodeFix({
161855
162783
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
161856
162784
  t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
161857
162785
  });
161858
- return [createCodeFixActionWithoutFixAll(fixId47, changes, Diagnostics.Remove_parentheses)];
162786
+ return [createCodeFixActionWithoutFixAll(fixId48, changes, Diagnostics.Remove_parentheses)];
161859
162787
  },
161860
- fixIds: [fixId47]
162788
+ fixIds: [fixId48]
161861
162789
  });
161862
162790
 
161863
162791
  // src/services/codefixes/removeUnnecessaryAwait.ts
161864
- var fixId48 = "removeUnnecessaryAwait";
161865
- var errorCodes61 = [
162792
+ var fixId49 = "removeUnnecessaryAwait";
162793
+ var errorCodes62 = [
161866
162794
  Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
161867
162795
  ];
161868
162796
  registerCodeFix({
161869
- errorCodes: errorCodes61,
162797
+ errorCodes: errorCodes62,
161870
162798
  getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
161871
162799
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span));
161872
162800
  if (changes.length > 0) {
161873
- return [createCodeFixAction(fixId48, changes, Diagnostics.Remove_unnecessary_await, fixId48, Diagnostics.Remove_all_unnecessary_uses_of_await)];
162801
+ return [createCodeFixAction(fixId49, changes, Diagnostics.Remove_unnecessary_await, fixId49, Diagnostics.Remove_all_unnecessary_uses_of_await)];
161874
162802
  }
161875
162803
  },
161876
- fixIds: [fixId48],
162804
+ fixIds: [fixId49],
161877
162805
  getAllCodeActions: (context) => {
161878
- return codeFixAll(context, errorCodes61, (changes, diag2) => makeChange11(changes, diag2.file, diag2));
162806
+ return codeFixAll(context, errorCodes62, (changes, diag2) => makeChange11(changes, diag2.file, diag2));
161879
162807
  }
161880
162808
  });
161881
162809
  function makeChange11(changeTracker, sourceFile, span) {
@@ -161903,20 +162831,20 @@ function makeChange11(changeTracker, sourceFile, span) {
161903
162831
  }
161904
162832
 
161905
162833
  // src/services/codefixes/splitTypeOnlyImport.ts
161906
- var errorCodes62 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
161907
- var fixId49 = "splitTypeOnlyImport";
162834
+ var errorCodes63 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
162835
+ var fixId50 = "splitTypeOnlyImport";
161908
162836
  registerCodeFix({
161909
- errorCodes: errorCodes62,
161910
- fixIds: [fixId49],
162837
+ errorCodes: errorCodes63,
162838
+ fixIds: [fixId50],
161911
162839
  getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
161912
162840
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
161913
162841
  return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
161914
162842
  });
161915
162843
  if (changes.length) {
161916
- return [createCodeFixAction(fixId49, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId49, Diagnostics.Split_all_invalid_type_only_imports)];
162844
+ return [createCodeFixAction(fixId50, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId50, Diagnostics.Split_all_invalid_type_only_imports)];
161917
162845
  }
161918
162846
  },
161919
- getAllCodeActions: (context) => codeFixAll(context, errorCodes62, (changes, error2) => {
162847
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes63, (changes, error2) => {
161920
162848
  splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error2), context);
161921
162849
  })
161922
162850
  });
@@ -161965,23 +162893,23 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
161965
162893
  }
161966
162894
 
161967
162895
  // src/services/codefixes/convertConstToLet.ts
161968
- var fixId50 = "fixConvertConstToLet";
161969
- var errorCodes63 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
162896
+ var fixId51 = "fixConvertConstToLet";
162897
+ var errorCodes64 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
161970
162898
  registerCodeFix({
161971
- errorCodes: errorCodes63,
162899
+ errorCodes: errorCodes64,
161972
162900
  getCodeActions: function getCodeActionsToConvertConstToLet(context) {
161973
162901
  const { sourceFile, span, program } = context;
161974
162902
  const info = getInfo21(sourceFile, span.start, program);
161975
162903
  if (info === void 0)
161976
162904
  return;
161977
162905
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange40(t, sourceFile, info.token));
161978
- return [createCodeFixActionMaybeFixAll(fixId50, changes, Diagnostics.Convert_const_to_let, fixId50, Diagnostics.Convert_all_const_to_let)];
162906
+ return [createCodeFixActionMaybeFixAll(fixId51, changes, Diagnostics.Convert_const_to_let, fixId51, Diagnostics.Convert_all_const_to_let)];
161979
162907
  },
161980
162908
  getAllCodeActions: (context) => {
161981
162909
  const { program } = context;
161982
162910
  const seen = /* @__PURE__ */ new Map();
161983
162911
  return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
161984
- eachDiagnostic(context, errorCodes63, (diag2) => {
162912
+ eachDiagnostic(context, errorCodes64, (diag2) => {
161985
162913
  const info = getInfo21(diag2.file, diag2.start, program);
161986
162914
  if (info) {
161987
162915
  if (addToSeen(seen, getSymbolId(info.symbol))) {
@@ -161992,7 +162920,7 @@ registerCodeFix({
161992
162920
  });
161993
162921
  }));
161994
162922
  },
161995
- fixIds: [fixId50]
162923
+ fixIds: [fixId51]
161996
162924
  });
161997
162925
  function getInfo21(sourceFile, pos, program) {
161998
162926
  var _a;
@@ -162013,11 +162941,11 @@ function doChange40(changes, sourceFile, token) {
162013
162941
  }
162014
162942
 
162015
162943
  // src/services/codefixes/fixExpectedComma.ts
162016
- var fixId51 = "fixExpectedComma";
162944
+ var fixId52 = "fixExpectedComma";
162017
162945
  var expectedErrorCode = Diagnostics._0_expected.code;
162018
- var errorCodes64 = [expectedErrorCode];
162946
+ var errorCodes65 = [expectedErrorCode];
162019
162947
  registerCodeFix({
162020
- errorCodes: errorCodes64,
162948
+ errorCodes: errorCodes65,
162021
162949
  getCodeActions(context) {
162022
162950
  const { sourceFile } = context;
162023
162951
  const info = getInfo22(sourceFile, context.span.start, context.errorCode);
@@ -162025,15 +162953,15 @@ registerCodeFix({
162025
162953
  return void 0;
162026
162954
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange41(t, sourceFile, info));
162027
162955
  return [createCodeFixAction(
162028
- fixId51,
162956
+ fixId52,
162029
162957
  changes,
162030
162958
  [Diagnostics.Change_0_to_1, ";", ","],
162031
- fixId51,
162959
+ fixId52,
162032
162960
  [Diagnostics.Change_0_to_1, ";", ","]
162033
162961
  )];
162034
162962
  },
162035
- fixIds: [fixId51],
162036
- getAllCodeActions: (context) => codeFixAll(context, errorCodes64, (changes, diag2) => {
162963
+ fixIds: [fixId52],
162964
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes65, (changes, diag2) => {
162037
162965
  const info = getInfo22(diag2.file, diag2.start, diag2.code);
162038
162966
  if (info)
162039
162967
  doChange41(changes, context.sourceFile, info);
@@ -162050,22 +162978,22 @@ function doChange41(changes, sourceFile, { node }) {
162050
162978
 
162051
162979
  // src/services/codefixes/fixAddVoidToPromise.ts
162052
162980
  var fixName7 = "addVoidToPromise";
162053
- var fixId52 = "addVoidToPromise";
162054
- var errorCodes65 = [
162981
+ var fixId53 = "addVoidToPromise";
162982
+ var errorCodes66 = [
162055
162983
  Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
162056
162984
  Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
162057
162985
  ];
162058
162986
  registerCodeFix({
162059
- errorCodes: errorCodes65,
162060
- fixIds: [fixId52],
162987
+ errorCodes: errorCodes66,
162988
+ fixIds: [fixId53],
162061
162989
  getCodeActions(context) {
162062
162990
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange12(t, context.sourceFile, context.span, context.program));
162063
162991
  if (changes.length > 0) {
162064
- return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId52, Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)];
162992
+ return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId53, Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)];
162065
162993
  }
162066
162994
  },
162067
162995
  getAllCodeActions(context) {
162068
- return codeFixAll(context, errorCodes65, (changes, diag2) => makeChange12(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
162996
+ return codeFixAll(context, errorCodes66, (changes, diag2) => makeChange12(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
162069
162997
  }
162070
162998
  });
162071
162999
  function makeChange12(changes, sourceFile, span, program, seen) {
@@ -190839,10 +191767,10 @@ ${e.message}`;
190839
191767
  }
190840
191768
  return simplifiedResult ? codeActions.map((codeAction) => this.mapCodeFixAction(codeAction)) : codeActions;
190841
191769
  }
190842
- getCombinedCodeFix({ scope, fixId: fixId53 }, simplifiedResult) {
191770
+ getCombinedCodeFix({ scope, fixId: fixId54 }, simplifiedResult) {
190843
191771
  Debug.assert(scope.type === "file");
190844
191772
  const { file, project } = this.getFileAndProject(scope.args);
190845
- const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId53, this.getFormatOptions(file), this.getPreferences(file));
191773
+ const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId54, this.getFormatOptions(file), this.getPreferences(file));
190846
191774
  if (simplifiedResult) {
190847
191775
  return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands };
190848
191776
  } else {
@@ -190881,8 +191809,8 @@ ${e.message}`;
190881
191809
  mapCodeAction({ description: description3, changes, commands }) {
190882
191810
  return { description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands };
190883
191811
  }
190884
- mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId: fixId53, fixAllDescription }) {
190885
- return { fixName: fixName8, description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId: fixId53, fixAllDescription };
191812
+ mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId: fixId54, fixAllDescription }) {
191813
+ return { fixName: fixName8, description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId: fixId54, fixAllDescription };
190886
191814
  }
190887
191815
  mapTextChangesToCodeEdits(textChanges2) {
190888
191816
  return textChanges2.map((change) => this.mapTextChangeToCodeEdit(change));