@typescript-deploys/pr-build 5.9.0-pr-61505-16 → 5.9.0-pr-61535-10

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/_tsc.js CHANGED
@@ -18,15 +18,11 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.9";
21
- var version = `${versionMajorMinor}.0-insiders.20250401`;
21
+ var version = `${versionMajorMinor}.0-insiders.20250416`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
25
25
  var emptyMap = /* @__PURE__ */ new Map();
26
- var voidMap = /* @__PURE__ */ new Map();
27
- voidMap.set = function() {
28
- return this;
29
- };
30
26
  function length(array) {
31
27
  return array !== void 0 ? array.length : 0;
32
28
  }
@@ -20017,6 +20013,82 @@ function getOptionsSyntaxByValue(optionsObject, name, value) {
20017
20013
  function forEachOptionsSyntaxByName(optionsObject, name, callback) {
20018
20014
  return forEachPropertyAssignment(optionsObject, name, callback);
20019
20015
  }
20016
+ function getSynthesizedDeepClone(node, includeTrivia = true) {
20017
+ const clone = node && getSynthesizedDeepCloneWorker(node);
20018
+ if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);
20019
+ return setParentRecursive(
20020
+ clone,
20021
+ /*incremental*/
20022
+ false
20023
+ );
20024
+ }
20025
+ function getSynthesizedDeepCloneWithReplacements(node, includeTrivia, replaceNode) {
20026
+ let clone = replaceNode(node);
20027
+ if (clone) {
20028
+ setOriginalNode(clone, node);
20029
+ } else {
20030
+ clone = getSynthesizedDeepCloneWorker(node, replaceNode);
20031
+ }
20032
+ if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);
20033
+ return clone;
20034
+ }
20035
+ function getSynthesizedDeepCloneWorker(node, replaceNode) {
20036
+ const nodeClone = replaceNode ? (n) => getSynthesizedDeepCloneWithReplacements(
20037
+ n,
20038
+ /*includeTrivia*/
20039
+ true,
20040
+ replaceNode
20041
+ ) : getSynthesizedDeepClone;
20042
+ const nodesClone = replaceNode ? (ns) => ns && getSynthesizedDeepClonesWithReplacements(
20043
+ ns,
20044
+ /*includeTrivia*/
20045
+ true,
20046
+ replaceNode
20047
+ ) : (ns) => ns && getSynthesizedDeepClones(ns);
20048
+ const visited = visitEachChild(
20049
+ node,
20050
+ nodeClone,
20051
+ /*context*/
20052
+ void 0,
20053
+ nodesClone,
20054
+ nodeClone
20055
+ );
20056
+ if (visited === node) {
20057
+ const clone = isStringLiteral(node) ? setOriginalNode(factory.createStringLiteralFromNode(node), node) : isNumericLiteral(node) ? setOriginalNode(factory.createNumericLiteral(node.text, node.numericLiteralFlags), node) : factory.cloneNode(node);
20058
+ return setTextRange(clone, node);
20059
+ }
20060
+ visited.parent = void 0;
20061
+ return visited;
20062
+ }
20063
+ function getSynthesizedDeepClones(nodes, includeTrivia = true) {
20064
+ if (nodes) {
20065
+ const cloned = factory.createNodeArray(nodes.map((n) => getSynthesizedDeepClone(n, includeTrivia)), nodes.hasTrailingComma);
20066
+ setTextRange(cloned, nodes);
20067
+ return cloned;
20068
+ }
20069
+ return nodes;
20070
+ }
20071
+ function getSynthesizedDeepClonesWithReplacements(nodes, includeTrivia, replaceNode) {
20072
+ return factory.createNodeArray(nodes.map((n) => getSynthesizedDeepCloneWithReplacements(n, includeTrivia, replaceNode)), nodes.hasTrailingComma);
20073
+ }
20074
+ function suppressLeadingAndTrailingTrivia(node) {
20075
+ suppressLeadingTrivia(node);
20076
+ suppressTrailingTrivia(node);
20077
+ }
20078
+ function suppressLeadingTrivia(node) {
20079
+ addEmitFlagsRecursively(node, 1024 /* NoLeadingComments */, getFirstChild);
20080
+ }
20081
+ function suppressTrailingTrivia(node) {
20082
+ addEmitFlagsRecursively(node, 2048 /* NoTrailingComments */, getLastChild);
20083
+ }
20084
+ function addEmitFlagsRecursively(node, flag, getChild) {
20085
+ addEmitFlags(node, flag);
20086
+ const child = getChild(node);
20087
+ if (child) addEmitFlagsRecursively(child, flag, getChild);
20088
+ }
20089
+ function getFirstChild(node) {
20090
+ return forEachChild(node, (child) => child);
20091
+ }
20020
20092
 
20021
20093
  // src/compiler/factory/baseNodeFactory.ts
20022
20094
  function createBaseNodeFactory() {
@@ -46380,11 +46452,11 @@ function createTypeChecker(host) {
46380
46452
  typePredicateToString: (predicate, enclosingDeclaration, flags) => {
46381
46453
  return typePredicateToString(predicate, getParseTreeNode(enclosingDeclaration), flags);
46382
46454
  },
46383
- writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => {
46384
- return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer);
46455
+ writeSignature: (signature, enclosingDeclaration, flags, kind, writer, verbosityLevel, out) => {
46456
+ return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer, verbosityLevel, out);
46385
46457
  },
46386
- writeType: (type, enclosingDeclaration, flags, writer) => {
46387
- return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer);
46458
+ writeType: (type, enclosingDeclaration, flags, writer, verbosityLevel, out) => {
46459
+ return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer, verbosityLevel, out);
46388
46460
  },
46389
46461
  writeSymbol: (symbol, enclosingDeclaration, meaning, flags, writer) => {
46390
46462
  return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
@@ -46618,7 +46690,8 @@ function createTypeChecker(host) {
46618
46690
  isTypeParameterPossiblyReferenced,
46619
46691
  typeHasCallOrConstructSignatures,
46620
46692
  getSymbolFlags,
46621
- getTypeArgumentsForResolvedSignature
46693
+ getTypeArgumentsForResolvedSignature,
46694
+ isLibType
46622
46695
  };
46623
46696
  function getTypeArgumentsForResolvedSignature(signature) {
46624
46697
  if (signature.mapper === void 0) return void 0;
@@ -46822,7 +46895,6 @@ function createTypeChecker(host) {
46822
46895
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
46823
46896
  var numericStringType = getTemplateLiteralType(["", ""], [numberType]);
46824
46897
  var restrictiveMapper = makeFunctionTypeMapper((t) => t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t, () => "(restrictive mapper)");
46825
- restrictiveMapper.instantiations = voidMap;
46826
46898
  var permissiveMapper = makeFunctionTypeMapper((t) => t.flags & 262144 /* TypeParameter */ ? wildcardType : t, () => "(permissive mapper)");
46827
46899
  var uniqueLiteralType = createIntrinsicType(
46828
46900
  131072 /* Never */,
@@ -46842,7 +46914,6 @@ function createTypeChecker(host) {
46842
46914
  }
46843
46915
  return t;
46844
46916
  }, () => "(unmeasurable reporter)");
46845
- reportUnreliableMapper.instantiations = voidMap;
46846
46917
  var reportUnmeasurableMapper = makeFunctionTypeMapper((t) => {
46847
46918
  if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) {
46848
46919
  outofbandVarianceMarkerHandler(
@@ -46852,7 +46923,6 @@ function createTypeChecker(host) {
46852
46923
  }
46853
46924
  return t;
46854
46925
  }, () => "(unreliable reporter)");
46855
- reportUnmeasurableMapper.instantiations = voidMap;
46856
46926
  var emptyObjectType = createAnonymousType(
46857
46927
  /*symbol*/
46858
46928
  void 0,
@@ -47133,6 +47203,9 @@ function createTypeChecker(host) {
47133
47203
  var inferenceContextNodes = [];
47134
47204
  var inferenceContexts = [];
47135
47205
  var inferenceContextCount = 0;
47206
+ var activeTypeMappers = [];
47207
+ var activeTypeMappersCaches = [];
47208
+ var activeTypeMappersCount = 0;
47136
47209
  var emptyStringType = getStringLiteralType("");
47137
47210
  var zeroType = getNumberLiteralType(0);
47138
47211
  var zeroBigIntType = getBigIntLiteralType({ negative: false, base10Value: "0" });
@@ -50298,7 +50371,7 @@ function createTypeChecker(host) {
50298
50371
  return writer2;
50299
50372
  }
50300
50373
  }
50301
- function signatureToString(signature, enclosingDeclaration, flags = 0 /* None */, kind, writer) {
50374
+ function signatureToString(signature, enclosingDeclaration, flags = 0 /* None */, kind, writer, verbosityLevel, out) {
50302
50375
  return writer ? signatureToStringWorker(writer).getText() : usingSingleLineStringWriter(signatureToStringWorker);
50303
50376
  function signatureToStringWorker(writer2) {
50304
50377
  let sigOutput;
@@ -50307,7 +50380,18 @@ function createTypeChecker(host) {
50307
50380
  } else {
50308
50381
  sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructSignature */ : 179 /* CallSignature */;
50309
50382
  }
50310
- const sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */);
50383
+ const sig = nodeBuilder.signatureToSignatureDeclaration(
50384
+ signature,
50385
+ sigOutput,
50386
+ enclosingDeclaration,
50387
+ toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */,
50388
+ /*internalFlags*/
50389
+ void 0,
50390
+ /*tracker*/
50391
+ void 0,
50392
+ verbosityLevel,
50393
+ out
50394
+ );
50311
50395
  const printer = createPrinterWithRemoveCommentsOmitTrailingSemicolon();
50312
50396
  const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration);
50313
50397
  printer.writeNode(
@@ -50320,14 +50404,18 @@ function createTypeChecker(host) {
50320
50404
  return writer2;
50321
50405
  }
50322
50406
  }
50323
- function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter("")) {
50407
+ function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter(""), verbosityLevel, out) {
50324
50408
  const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */;
50325
50409
  const typeNode = nodeBuilder.typeToTypeNode(
50326
50410
  type,
50327
50411
  enclosingDeclaration,
50328
- toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0 /* None */),
50412
+ toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0),
50329
50413
  /*internalFlags*/
50330
- void 0
50414
+ void 0,
50415
+ /*tracker*/
50416
+ void 0,
50417
+ verbosityLevel,
50418
+ out
50331
50419
  );
50332
50420
  if (typeNode === void 0) return Debug.fail("should always get typenode");
50333
50421
  const printer = type !== unresolvedType ? createPrinterWithRemoveComments() : createPrinterWithDefaults();
@@ -50406,7 +50494,6 @@ function createTypeChecker(host) {
50406
50494
  },
50407
50495
  isOptionalParameter,
50408
50496
  isUndefinedIdentifierExpression(node) {
50409
- Debug.assert(isExpressionNode(node));
50410
50497
  return getSymbolAtLocation(node) === undefinedSymbol;
50411
50498
  },
50412
50499
  isEntityNameVisible(context, entityName, shouldComputeAliasToMakeVisible) {
@@ -50558,31 +50645,120 @@ function createTypeChecker(host) {
50558
50645
  };
50559
50646
  return {
50560
50647
  syntacticBuilderResolver,
50561
- typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeToTypeNodeHelper(type, context)),
50562
- typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
50563
- serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)),
50564
- serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)),
50565
- serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)),
50566
- indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
50567
- indexInfo,
50568
- context,
50569
- /*typeNode*/
50570
- void 0
50571
- )),
50572
- signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => signatureToSignatureDeclarationHelper(signature, kind, context)),
50573
- symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToName(
50574
- symbol,
50575
- context,
50576
- meaning,
50577
- /*expectsIdentifier*/
50578
- false
50579
- )),
50580
- symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToExpression(symbol, context, meaning)),
50581
- symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
50582
- symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
50583
- typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
50584
- symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
50585
- symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToNode(symbol, context, meaning))
50648
+ typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeToTypeNodeHelper(type, context), out),
50649
+ typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50650
+ enclosingDeclaration,
50651
+ flags,
50652
+ internalFlags,
50653
+ tracker,
50654
+ /*verbosityLevel*/
50655
+ void 0,
50656
+ (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)
50657
+ ),
50658
+ serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50659
+ enclosingDeclaration,
50660
+ flags,
50661
+ internalFlags,
50662
+ tracker,
50663
+ /*verbosityLevel*/
50664
+ void 0,
50665
+ (context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)
50666
+ ),
50667
+ serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50668
+ enclosingDeclaration,
50669
+ flags,
50670
+ internalFlags,
50671
+ tracker,
50672
+ /*verbosityLevel*/
50673
+ void 0,
50674
+ (context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)
50675
+ ),
50676
+ serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50677
+ enclosingDeclaration,
50678
+ flags,
50679
+ internalFlags,
50680
+ tracker,
50681
+ /*verbosityLevel*/
50682
+ void 0,
50683
+ (context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)
50684
+ ),
50685
+ indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50686
+ enclosingDeclaration,
50687
+ flags,
50688
+ internalFlags,
50689
+ tracker,
50690
+ /*verbosityLevel*/
50691
+ void 0,
50692
+ (context) => indexInfoToIndexSignatureDeclarationHelper(
50693
+ indexInfo,
50694
+ context,
50695
+ /*typeNode*/
50696
+ void 0
50697
+ )
50698
+ ),
50699
+ signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => signatureToSignatureDeclarationHelper(signature, kind, context), out),
50700
+ symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50701
+ enclosingDeclaration,
50702
+ flags,
50703
+ internalFlags,
50704
+ tracker,
50705
+ /*verbosityLevel*/
50706
+ void 0,
50707
+ (context) => symbolToName(
50708
+ symbol,
50709
+ context,
50710
+ meaning,
50711
+ /*expectsIdentifier*/
50712
+ false
50713
+ )
50714
+ ),
50715
+ symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50716
+ enclosingDeclaration,
50717
+ flags,
50718
+ internalFlags,
50719
+ tracker,
50720
+ /*verbosityLevel*/
50721
+ void 0,
50722
+ (context) => symbolToExpression(symbol, context, meaning)
50723
+ ),
50724
+ symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50725
+ enclosingDeclaration,
50726
+ flags,
50727
+ internalFlags,
50728
+ tracker,
50729
+ /*verbosityLevel*/
50730
+ void 0,
50731
+ (context) => typeParametersToTypeParameterDeclarations(symbol, context)
50732
+ ),
50733
+ symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50734
+ enclosingDeclaration,
50735
+ flags,
50736
+ internalFlags,
50737
+ tracker,
50738
+ /*verbosityLevel*/
50739
+ void 0,
50740
+ (context) => symbolToParameterDeclaration(symbol, context)
50741
+ ),
50742
+ typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeParameterToDeclaration(parameter, context), out),
50743
+ symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50744
+ enclosingDeclaration,
50745
+ flags,
50746
+ internalFlags,
50747
+ tracker,
50748
+ /*verbosityLevel*/
50749
+ void 0,
50750
+ (context) => symbolTableToDeclarationStatements(symbolTable, context)
50751
+ ),
50752
+ symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50753
+ enclosingDeclaration,
50754
+ flags,
50755
+ internalFlags,
50756
+ tracker,
50757
+ /*verbosityLevel*/
50758
+ void 0,
50759
+ (context) => symbolToNode(symbol, context, meaning)
50760
+ ),
50761
+ symbolToDeclarations
50586
50762
  };
50587
50763
  function getTypeFromTypeNode2(context, node, noMappedTypes) {
50588
50764
  const type = getTypeFromTypeNodeWithoutContext(node);
@@ -50624,7 +50800,75 @@ function createTypeChecker(host) {
50624
50800
  }
50625
50801
  return symbolToExpression(symbol, context, meaning);
50626
50802
  }
50627
- function withContext(enclosingDeclaration, flags, internalFlags, tracker, cb) {
50803
+ function symbolToDeclarations(symbol, meaning, flags, verbosityLevel, out) {
50804
+ const nodes = withContext(
50805
+ /*enclosingDeclaration*/
50806
+ void 0,
50807
+ flags,
50808
+ /*internalFlags*/
50809
+ void 0,
50810
+ /*tracker*/
50811
+ void 0,
50812
+ verbosityLevel,
50813
+ (context) => symbolToDeclarationsWorker(symbol, context),
50814
+ out
50815
+ );
50816
+ return mapDefined(nodes, (node) => {
50817
+ switch (node.kind) {
50818
+ case 263 /* ClassDeclaration */:
50819
+ return simplifyClassDeclaration(node, symbol);
50820
+ case 266 /* EnumDeclaration */:
50821
+ return simplifyModifiers(node, isEnumDeclaration, symbol);
50822
+ case 264 /* InterfaceDeclaration */:
50823
+ return simplifyInterfaceDeclaration(node, symbol, meaning);
50824
+ case 267 /* ModuleDeclaration */:
50825
+ return simplifyModifiers(node, isModuleDeclaration, symbol);
50826
+ default:
50827
+ return void 0;
50828
+ }
50829
+ });
50830
+ }
50831
+ function simplifyClassDeclaration(classDecl, symbol) {
50832
+ const classDeclarations = filter(symbol.declarations, isClassLike);
50833
+ const originalClassDecl = classDeclarations && classDeclarations.length > 0 ? classDeclarations[0] : classDecl;
50834
+ const modifiers = getEffectiveModifierFlags(originalClassDecl) & ~(32 /* Export */ | 128 /* Ambient */);
50835
+ const isAnonymous = isClassExpression(originalClassDecl);
50836
+ if (isAnonymous) {
50837
+ classDecl = factory.updateClassDeclaration(
50838
+ classDecl,
50839
+ classDecl.modifiers,
50840
+ /*name*/
50841
+ void 0,
50842
+ classDecl.typeParameters,
50843
+ classDecl.heritageClauses,
50844
+ classDecl.members
50845
+ );
50846
+ }
50847
+ return factory.replaceModifiers(classDecl, modifiers);
50848
+ }
50849
+ function simplifyModifiers(newDecl, isDeclKind, symbol) {
50850
+ const decls = filter(symbol.declarations, isDeclKind);
50851
+ const declWithModifiers = decls && decls.length > 0 ? decls[0] : newDecl;
50852
+ const modifiers = getEffectiveModifierFlags(declWithModifiers) & ~(32 /* Export */ | 128 /* Ambient */);
50853
+ return factory.replaceModifiers(newDecl, modifiers);
50854
+ }
50855
+ function simplifyInterfaceDeclaration(interfaceDecl, symbol, meaning) {
50856
+ if (!(meaning & 64 /* Interface */)) {
50857
+ return void 0;
50858
+ }
50859
+ return simplifyModifiers(interfaceDecl, isInterfaceDeclaration, symbol);
50860
+ }
50861
+ function symbolToDeclarationsWorker(symbol, context) {
50862
+ const type = getDeclaredTypeOfSymbol(symbol);
50863
+ context.typeStack.push(type.id);
50864
+ context.typeStack.push(-1);
50865
+ const table = createSymbolTable([symbol]);
50866
+ const statements = symbolTableToDeclarationStatements(table, context);
50867
+ context.typeStack.pop();
50868
+ context.typeStack.pop();
50869
+ return statements;
50870
+ }
50871
+ function withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, cb, out) {
50628
50872
  const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : (internalFlags || 0 /* None */) & 4 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
50629
50873
  const context = {
50630
50874
  enclosingDeclaration,
@@ -50632,6 +50876,7 @@ function createTypeChecker(host) {
50632
50876
  flags: flags || 0 /* None */,
50633
50877
  internalFlags: internalFlags || 0 /* None */,
50634
50878
  tracker: void 0,
50879
+ maxExpansionDepth: verbosityLevel ?? -1,
50635
50880
  encounteredError: false,
50636
50881
  suppressReportInferenceFallback: false,
50637
50882
  reportedDiagnostic: false,
@@ -50653,13 +50898,23 @@ function createTypeChecker(host) {
50653
50898
  typeParameterNamesByText: void 0,
50654
50899
  typeParameterNamesByTextNextNameCount: void 0,
50655
50900
  enclosingSymbolTypes: /* @__PURE__ */ new Map(),
50656
- mapper: void 0
50901
+ mapper: void 0,
50902
+ depth: 0,
50903
+ typeStack: [],
50904
+ out: {
50905
+ canIncreaseExpansionDepth: false,
50906
+ truncated: false
50907
+ }
50657
50908
  };
50658
50909
  context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
50659
50910
  const resultingNode = cb(context);
50660
50911
  if (context.truncating && context.flags & 1 /* NoTruncation */) {
50661
50912
  context.tracker.reportTruncationError();
50662
50913
  }
50914
+ if (out) {
50915
+ out.canIncreaseExpansionDepth = context.out.canIncreaseExpansionDepth;
50916
+ out.truncated = context.out.truncated;
50917
+ }
50663
50918
  return context.encounteredError ? void 0 : resultingNode;
50664
50919
  }
50665
50920
  function addSymbolTypeToContext(context, symbol, type) {
@@ -50678,19 +50933,49 @@ function createTypeChecker(host) {
50678
50933
  function saveRestoreFlags(context) {
50679
50934
  const flags = context.flags;
50680
50935
  const internalFlags = context.internalFlags;
50936
+ const depth = context.depth;
50681
50937
  return restore;
50682
50938
  function restore() {
50683
50939
  context.flags = flags;
50684
50940
  context.internalFlags = internalFlags;
50941
+ context.depth = depth;
50685
50942
  }
50686
50943
  }
50944
+ function checkTruncationLengthIfExpanding(context) {
50945
+ return context.maxExpansionDepth >= 0 && checkTruncationLength(context);
50946
+ }
50687
50947
  function checkTruncationLength(context) {
50688
50948
  if (context.truncating) return context.truncating;
50689
50949
  return context.truncating = context.approximateLength > (context.flags & 1 /* NoTruncation */ ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
50690
50950
  }
50951
+ function canPossiblyExpandType(type, context) {
50952
+ for (let i = 0; i < context.typeStack.length - 1; i++) {
50953
+ if (context.typeStack[i] === type.id) {
50954
+ return false;
50955
+ }
50956
+ }
50957
+ return context.depth < context.maxExpansionDepth || context.depth === context.maxExpansionDepth && !context.out.canIncreaseExpansionDepth;
50958
+ }
50959
+ function shouldExpandType(type, context, isAlias = false) {
50960
+ if (!isAlias && isLibType(type)) {
50961
+ return false;
50962
+ }
50963
+ for (let i = 0; i < context.typeStack.length - 1; i++) {
50964
+ if (context.typeStack[i] === type.id) {
50965
+ return false;
50966
+ }
50967
+ }
50968
+ const result = context.depth < context.maxExpansionDepth;
50969
+ if (!result) {
50970
+ context.out.canIncreaseExpansionDepth = true;
50971
+ }
50972
+ return result;
50973
+ }
50691
50974
  function typeToTypeNodeHelper(type, context) {
50692
50975
  const restoreFlags = saveRestoreFlags(context);
50976
+ if (type) context.typeStack.push(type.id);
50693
50977
  const typeNode = typeToTypeNodeWorker(type, context);
50978
+ if (type) context.typeStack.pop();
50694
50979
  restoreFlags();
50695
50980
  return typeNode;
50696
50981
  }
@@ -50701,6 +50986,7 @@ function createTypeChecker(host) {
50701
50986
  }
50702
50987
  const inTypeAlias = context.flags & 8388608 /* InTypeAlias */;
50703
50988
  context.flags &= ~8388608 /* InTypeAlias */;
50989
+ let expandingEnum = false;
50704
50990
  if (!type) {
50705
50991
  if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) {
50706
50992
  context.encounteredError = true;
@@ -50768,7 +51054,11 @@ function createTypeChecker(host) {
50768
51054
  return Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
50769
51055
  }
50770
51056
  }
50771
- return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
51057
+ if (!shouldExpandType(type, context)) {
51058
+ return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
51059
+ } else {
51060
+ expandingEnum = true;
51061
+ }
50772
51062
  }
50773
51063
  if (type.flags & 128 /* StringLiteral */) {
50774
51064
  context.approximateLength += type.value.length + 2;
@@ -50835,16 +51125,34 @@ function createTypeChecker(host) {
50835
51125
  return factory.createThisTypeNode();
50836
51126
  }
50837
51127
  if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
50838
- const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
50839
- if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
50840
- if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
50841
- return factory.createArrayTypeNode(typeArgumentNodes[0]);
51128
+ if (!shouldExpandType(
51129
+ type,
51130
+ context,
51131
+ /*isAlias*/
51132
+ true
51133
+ )) {
51134
+ const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
51135
+ if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
51136
+ if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
51137
+ return factory.createArrayTypeNode(typeArgumentNodes[0]);
51138
+ }
51139
+ return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
50842
51140
  }
50843
- return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
51141
+ context.depth += 1;
50844
51142
  }
50845
51143
  const objectFlags = getObjectFlags(type);
50846
51144
  if (objectFlags & 4 /* Reference */) {
50847
51145
  Debug.assert(!!(type.flags & 524288 /* Object */));
51146
+ if (shouldExpandType(type, context)) {
51147
+ context.depth += 1;
51148
+ return createAnonymousTypeNode(
51149
+ type,
51150
+ /*forceClassExpansion*/
51151
+ true,
51152
+ /*forceExpansion*/
51153
+ true
51154
+ );
51155
+ }
50848
51156
  return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
50849
51157
  }
50850
51158
  if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
@@ -50874,6 +51182,16 @@ function createTypeChecker(host) {
50874
51182
  void 0
50875
51183
  );
50876
51184
  }
51185
+ if (objectFlags & 3 /* ClassOrInterface */ && shouldExpandType(type, context)) {
51186
+ context.depth += 1;
51187
+ return createAnonymousTypeNode(
51188
+ type,
51189
+ /*forceClassExpansion*/
51190
+ true,
51191
+ /*forceExpansion*/
51192
+ true
51193
+ );
51194
+ }
50877
51195
  if (type.symbol) {
50878
51196
  return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
50879
51197
  }
@@ -50888,7 +51206,7 @@ function createTypeChecker(host) {
50888
51206
  type = type.origin;
50889
51207
  }
50890
51208
  if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
50891
- const types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types;
51209
+ const types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types, expandingEnum) : type.types;
50892
51210
  if (length(types) === 1) {
50893
51211
  return typeToTypeNodeHelper(types[0], context);
50894
51212
  }
@@ -51077,7 +51395,7 @@ function createTypeChecker(host) {
51077
51395
  }
51078
51396
  return result;
51079
51397
  }
51080
- function createAnonymousTypeNode(type2) {
51398
+ function createAnonymousTypeNode(type2, forceClassExpansion = false, forceExpansion = false) {
51081
51399
  var _a2, _b2;
51082
51400
  const typeId = type2.id;
51083
51401
  const symbol = type2.symbol;
@@ -51100,15 +51418,20 @@ function createTypeChecker(host) {
51100
51418
  const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
51101
51419
  if (isJSConstructor(symbol.valueDeclaration)) {
51102
51420
  return symbolToTypeNode(symbol, context, isInstanceType);
51103
- } else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
51421
+ } else if (!forceExpansion && (symbol.flags & 32 /* Class */ && !forceClassExpansion && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
51104
51422
  symbol,
51105
51423
  context.enclosingDeclaration,
51106
51424
  isInstanceType,
51107
51425
  /*shouldComputeAliasesToMakeVisible*/
51108
51426
  false
51109
- ).accessibility !== 0 /* Accessible */)) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) {
51110
- return symbolToTypeNode(symbol, context, isInstanceType);
51111
- } else if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
51427
+ ).accessibility !== 0 /* Accessible */)) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol())) {
51428
+ if (shouldExpandType(type2, context)) {
51429
+ context.depth += 1;
51430
+ } else {
51431
+ return symbolToTypeNode(symbol, context, isInstanceType);
51432
+ }
51433
+ }
51434
+ if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
51112
51435
  const typeAlias = getTypeAliasForTypeLiteral(type2);
51113
51436
  if (typeAlias) {
51114
51437
  return symbolToTypeNode(typeAlias, context, 788968 /* Type */);
@@ -51144,7 +51467,7 @@ function createTypeChecker(host) {
51144
51467
  if (id && !context.symbolDepth) {
51145
51468
  context.symbolDepth = /* @__PURE__ */ new Map();
51146
51469
  }
51147
- const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
51470
+ const links = context.maxExpansionDepth >= 0 ? void 0 : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
51148
51471
  const key = `${getTypeId(type2)}|${context.flags}|${context.internalFlags}`;
51149
51472
  if (links) {
51150
51473
  links.serializedTypes || (links.serializedTypes = /* @__PURE__ */ new Map());
@@ -51461,6 +51784,7 @@ function createTypeChecker(host) {
51461
51784
  }
51462
51785
  function createTypeNodesFromResolvedType(resolvedType) {
51463
51786
  if (checkTruncationLength(context)) {
51787
+ context.out.truncated = true;
51464
51788
  if (context.flags & 1 /* NoTruncation */) {
51465
51789
  return [addSyntheticTrailingComment(factory.createNotEmittedTypeElement(), 3 /* MultiLineCommentTrivia */, "elided")];
51466
51790
  }
@@ -51474,6 +51798,7 @@ function createTypeChecker(host) {
51474
51798
  void 0
51475
51799
  )];
51476
51800
  }
51801
+ context.typeStack.push(-1);
51477
51802
  const typeElements = [];
51478
51803
  for (const signature of resolvedType.callSignatures) {
51479
51804
  typeElements.push(signatureToSignatureDeclarationHelper(signature, 179 /* CallSignature */, context));
@@ -51487,10 +51812,14 @@ function createTypeChecker(host) {
51487
51812
  }
51488
51813
  const properties = resolvedType.properties;
51489
51814
  if (!properties) {
51815
+ context.typeStack.pop();
51490
51816
  return typeElements;
51491
51817
  }
51492
51818
  let i = 0;
51493
51819
  for (const propertySymbol of properties) {
51820
+ if (isExpanding(context) && propertySymbol.flags & 4194304 /* Prototype */) {
51821
+ continue;
51822
+ }
51494
51823
  i++;
51495
51824
  if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) {
51496
51825
  if (propertySymbol.flags & 4194304 /* Prototype */) {
@@ -51501,6 +51830,7 @@ function createTypeChecker(host) {
51501
51830
  }
51502
51831
  }
51503
51832
  if (checkTruncationLength(context) && i + 2 < properties.length - 1) {
51833
+ context.out.truncated = true;
51504
51834
  if (context.flags & 1 /* NoTruncation */) {
51505
51835
  const typeElement = typeElements.pop();
51506
51836
  typeElements.push(addSyntheticTrailingComment(typeElement, 3 /* MultiLineCommentTrivia */, `... ${properties.length - i} more elided ...`));
@@ -51520,6 +51850,7 @@ function createTypeChecker(host) {
51520
51850
  }
51521
51851
  addPropertyToElementList(propertySymbol, context, typeElements);
51522
51852
  }
51853
+ context.typeStack.pop();
51523
51854
  return typeElements.length ? typeElements : void 0;
51524
51855
  }
51525
51856
  }
@@ -51668,6 +51999,7 @@ function createTypeChecker(host) {
51668
51999
  function mapToTypeNodes(types, context, isBareList) {
51669
52000
  if (some(types)) {
51670
52001
  if (checkTruncationLength(context)) {
52002
+ context.out.truncated = true;
51671
52003
  if (!isBareList) {
51672
52004
  return [
51673
52005
  context.flags & 1 /* NoTruncation */ ? addSyntheticLeadingComment(factory.createKeywordTypeNode(133 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "elided") : factory.createTypeReferenceNode(
@@ -51695,6 +52027,7 @@ function createTypeChecker(host) {
51695
52027
  for (const type of types) {
51696
52028
  i++;
51697
52029
  if (checkTruncationLength(context) && i + 2 < types.length - 1) {
52030
+ context.out.truncated = true;
51698
52031
  result.push(
51699
52032
  context.flags & 1 /* NoTruncation */ ? addSyntheticLeadingComment(factory.createKeywordTypeNode(133 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, `... ${types.length - i} more elided ...`) : factory.createTypeReferenceNode(
51700
52033
  `... ${types.length - i} more ...`,
@@ -52092,7 +52425,7 @@ function createTypeChecker(host) {
52092
52425
  return factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
52093
52426
  }
52094
52427
  function typeToTypeNodeHelperWithPossibleReusableTypeNode(type, typeNode, context) {
52095
- return typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
52428
+ return !canPossiblyExpandType(type, context) && typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
52096
52429
  }
52097
52430
  function typeParameterToDeclaration(type, context, constraint = getConstraintOfTypeParameter(type)) {
52098
52431
  const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context);
@@ -52611,12 +52944,15 @@ function createTypeChecker(host) {
52611
52944
  }
52612
52945
  let firstChar = symbolName2.charCodeAt(0);
52613
52946
  if (isSingleOrDoubleQuote(firstChar) && some(symbol2.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
52614
- return factory.createStringLiteral(getSpecifierForModuleSymbol(symbol2, context));
52947
+ const specifier = getSpecifierForModuleSymbol(symbol2, context);
52948
+ context.approximateLength += 2 + specifier.length;
52949
+ return factory.createStringLiteral(specifier);
52615
52950
  }
52616
52951
  if (index === 0 || canUsePropertyAccess(symbolName2, languageVersion)) {
52617
52952
  const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
52618
52953
  if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
52619
52954
  identifier.symbol = symbol2;
52955
+ context.approximateLength += 1 + symbolName2.length;
52620
52956
  return index > 0 ? factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), identifier) : identifier;
52621
52957
  } else {
52622
52958
  if (firstChar === 91 /* openBracket */) {
@@ -52625,16 +52961,21 @@ function createTypeChecker(host) {
52625
52961
  }
52626
52962
  let expression;
52627
52963
  if (isSingleOrDoubleQuote(firstChar) && !(symbol2.flags & 8 /* EnumMember */)) {
52628
- expression = factory.createStringLiteral(stripQuotes(symbolName2).replace(/\\./g, (s) => s.substring(1)), firstChar === 39 /* singleQuote */);
52964
+ const literalText = stripQuotes(symbolName2).replace(/\\./g, (s) => s.substring(1));
52965
+ context.approximateLength += literalText.length + 2;
52966
+ expression = factory.createStringLiteral(literalText, firstChar === 39 /* singleQuote */);
52629
52967
  } else if ("" + +symbolName2 === symbolName2) {
52968
+ context.approximateLength += symbolName2.length;
52630
52969
  expression = factory.createNumericLiteral(+symbolName2);
52631
52970
  }
52632
52971
  if (!expression) {
52633
52972
  const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
52634
52973
  if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
52635
52974
  identifier.symbol = symbol2;
52975
+ context.approximateLength += symbolName2.length;
52636
52976
  expression = identifier;
52637
52977
  }
52978
+ context.approximateLength += 2;
52638
52979
  return factory.createElementAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), expression);
52639
52980
  }
52640
52981
  }
@@ -52663,6 +53004,10 @@ function createTypeChecker(host) {
52663
53004
  ), "'")));
52664
53005
  }
52665
53006
  function getPropertyNameNodeForSymbol(symbol, context) {
53007
+ const hashPrivateName = getClonedHashPrivateName(symbol);
53008
+ if (hashPrivateName) {
53009
+ return hashPrivateName;
53010
+ }
52666
53011
  const stringNamed = !!length(symbol.declarations) && every(symbol.declarations, isStringNamed);
52667
53012
  const singleQuote = !!length(symbol.declarations) && every(symbol.declarations, isSingleQuotedStringNamed);
52668
53013
  const isMethod = !!(symbol.flags & 8192 /* Method */);
@@ -52739,7 +53084,7 @@ function createTypeChecker(host) {
52739
53084
  let result;
52740
53085
  const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
52741
53086
  const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
52742
- if (decl) {
53087
+ if (!canPossiblyExpandType(type, context) && decl) {
52743
53088
  const restore = addSymbolTypeToContext(context, symbol, type);
52744
53089
  if (isAccessor(decl)) {
52745
53090
  result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
@@ -52778,7 +53123,7 @@ function createTypeChecker(host) {
52778
53123
  let returnTypeNode;
52779
53124
  const returnType = getReturnTypeOfSignature(signature);
52780
53125
  if (!(suppressAny && isTypeAny(returnType))) {
52781
- if (signature.declaration && !nodeIsSynthesized(signature.declaration)) {
53126
+ if (signature.declaration && !nodeIsSynthesized(signature.declaration) && !canPossiblyExpandType(returnType, context)) {
52782
53127
  const declarationSymbol = getSymbolOfDeclaration(signature.declaration);
52783
53128
  const restore = addSymbolTypeToContext(context, declarationSymbol, returnType);
52784
53129
  returnTypeNode = syntacticNodeBuilder.serializeReturnTypeForSignature(signature.declaration, declarationSymbol, context);
@@ -53189,14 +53534,28 @@ function createTypeChecker(host) {
53189
53534
  if (!suppressNewPrivateContext) {
53190
53535
  deferredPrivatesStack.push(/* @__PURE__ */ new Map());
53191
53536
  }
53192
- symbolTable2.forEach((symbol) => {
53537
+ let i = 0;
53538
+ const symbols = Array.from(symbolTable2.values());
53539
+ for (const symbol of symbols) {
53540
+ i++;
53541
+ if (checkTruncationLengthIfExpanding(context) && i + 2 < symbolTable2.size - 1) {
53542
+ context.out.truncated = true;
53543
+ results.push(createTruncationStatement(`... (${symbolTable2.size - i} more ...)`));
53544
+ serializeSymbol(
53545
+ symbols[symbols.length - 1],
53546
+ /*isPrivate*/
53547
+ false,
53548
+ !!propertyAsAlias
53549
+ );
53550
+ break;
53551
+ }
53193
53552
  serializeSymbol(
53194
53553
  symbol,
53195
53554
  /*isPrivate*/
53196
53555
  false,
53197
53556
  !!propertyAsAlias
53198
53557
  );
53199
- });
53558
+ }
53200
53559
  if (!suppressNewPrivateContext) {
53201
53560
  deferredPrivatesStack[deferredPrivatesStack.length - 1].forEach((symbol) => {
53202
53561
  serializeSymbol(
@@ -53226,7 +53585,7 @@ function createTypeChecker(host) {
53226
53585
  }
53227
53586
  }
53228
53587
  function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias, escapedSymbolName = symbol.escapedName) {
53229
- var _a2, _b, _c, _d, _e, _f;
53588
+ var _a2, _b, _c, _d, _e, _f, _g;
53230
53589
  const symbolName2 = unescapeLeadingUnderscores(escapedSymbolName);
53231
53590
  const isDefault = escapedSymbolName === "default" /* Default */;
53232
53591
  if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && isStringANonContextualKeyword(symbolName2) && !isDefault) {
@@ -53276,6 +53635,7 @@ function createTypeChecker(host) {
53276
53635
  const propertyAccessRequire = (_e = symbol.declarations) == null ? void 0 : _e.find(isPropertyAccessExpression);
53277
53636
  if (propertyAccessRequire && isBinaryExpression(propertyAccessRequire.parent) && isIdentifier(propertyAccessRequire.parent.right) && ((_f = type.symbol) == null ? void 0 : _f.valueDeclaration) && isSourceFile(type.symbol.valueDeclaration)) {
53278
53637
  const alias = localName === propertyAccessRequire.parent.right.escapedText ? void 0 : propertyAccessRequire.parent.right;
53638
+ context.approximateLength += 12 + (((_g = alias == null ? void 0 : alias.escapedText) == null ? void 0 : _g.length) ?? 0);
53279
53639
  addResult(
53280
53640
  factory.createExportDeclaration(
53281
53641
  /*modifiers*/
@@ -53315,8 +53675,10 @@ function createTypeChecker(host) {
53315
53675
  ),
53316
53676
  textRange
53317
53677
  );
53678
+ context.approximateLength += 7 + name.length;
53318
53679
  addResult(statement, name !== localName ? modifierFlags & ~32 /* Export */ : modifierFlags);
53319
53680
  if (name !== localName && !isPrivate) {
53681
+ context.approximateLength += 16 + name.length + localName.length;
53320
53682
  addResult(
53321
53683
  factory.createExportDeclaration(
53322
53684
  /*modifiers*/
@@ -53366,27 +53728,33 @@ function createTypeChecker(host) {
53366
53728
  for (const node of symbol.declarations) {
53367
53729
  const resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
53368
53730
  if (!resolvedModule) continue;
53731
+ const isTypeOnly = node.isTypeOnly;
53732
+ const specifier = getSpecifierForModuleSymbol(resolvedModule, context);
53733
+ context.approximateLength += 17 + specifier.length;
53369
53734
  addResult(factory.createExportDeclaration(
53370
53735
  /*modifiers*/
53371
53736
  void 0,
53372
- /*isTypeOnly*/
53373
- node.isTypeOnly,
53737
+ isTypeOnly,
53374
53738
  /*exportClause*/
53375
53739
  void 0,
53376
- factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))
53740
+ factory.createStringLiteral(specifier)
53377
53741
  ), 0 /* None */);
53378
53742
  }
53379
53743
  }
53380
53744
  }
53381
53745
  if (needsPostExportDefault) {
53746
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53747
+ context.approximateLength += 16 + internalSymbolName.length;
53382
53748
  addResult(factory.createExportAssignment(
53383
53749
  /*modifiers*/
53384
53750
  void 0,
53385
53751
  /*isExportEquals*/
53386
53752
  false,
53387
- factory.createIdentifier(getInternalSymbolName(symbol, symbolName2))
53753
+ factory.createIdentifier(internalSymbolName)
53388
53754
  ), 0 /* None */);
53389
53755
  } else if (needsExportDeclaration) {
53756
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53757
+ context.approximateLength += 22 + symbolName2.length + internalSymbolName.length;
53390
53758
  addResult(
53391
53759
  factory.createExportDeclaration(
53392
53760
  /*modifiers*/
@@ -53396,7 +53764,7 @@ function createTypeChecker(host) {
53396
53764
  factory.createNamedExports([factory.createExportSpecifier(
53397
53765
  /*isTypeOnly*/
53398
53766
  false,
53399
- getInternalSymbolName(symbol, symbolName2),
53767
+ internalSymbolName,
53400
53768
  symbolName2
53401
53769
  )])
53402
53770
  ),
@@ -53416,6 +53784,7 @@ function createTypeChecker(host) {
53416
53784
  }
53417
53785
  function addResult(node, additionalModifierFlags) {
53418
53786
  if (canHaveModifiers(node)) {
53787
+ const oldModifierFlags = getEffectiveModifierFlags(node);
53419
53788
  let newModifierFlags = 0 /* None */;
53420
53789
  const enclosingDeclaration2 = context.enclosingDeclaration && (isJSDocTypeAlias(context.enclosingDeclaration) ? getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
53421
53790
  if (additionalModifierFlags & 32 /* Export */ && enclosingDeclaration2 && (isExportingScope(enclosingDeclaration2) || isModuleDeclaration(enclosingDeclaration2)) && canHaveExportModifier(node)) {
@@ -53428,8 +53797,9 @@ function createTypeChecker(host) {
53428
53797
  newModifierFlags |= 2048 /* Default */;
53429
53798
  }
53430
53799
  if (newModifierFlags) {
53431
- node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node));
53800
+ node = factory.replaceModifiers(node, newModifierFlags | oldModifierFlags);
53432
53801
  }
53802
+ context.approximateLength += modifiersLength(newModifierFlags | oldModifierFlags);
53433
53803
  }
53434
53804
  results.push(node);
53435
53805
  }
@@ -53445,12 +53815,14 @@ function createTypeChecker(host) {
53445
53815
  const oldEnclosingDecl = context.enclosingDeclaration;
53446
53816
  context.enclosingDeclaration = jsdocAliasDecl;
53447
53817
  const typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && syntacticNodeBuilder.tryReuseExistingTypeNode(context, jsdocAliasDecl.typeExpression.type) || typeToTypeNodeHelper(aliasType, context);
53818
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53819
+ context.approximateLength += 8 + ((commentText == null ? void 0 : commentText.length) ?? 0) + internalSymbolName.length;
53448
53820
  addResult(
53449
53821
  setSyntheticLeadingComments(
53450
53822
  factory.createTypeAliasDeclaration(
53451
53823
  /*modifiers*/
53452
53824
  void 0,
53453
- getInternalSymbolName(symbol, symbolName2),
53825
+ internalSymbolName,
53454
53826
  typeParamDecls,
53455
53827
  typeNode
53456
53828
  ),
@@ -53462,12 +53834,19 @@ function createTypeChecker(host) {
53462
53834
  context.enclosingDeclaration = oldEnclosingDecl;
53463
53835
  }
53464
53836
  function serializeInterface(symbol, symbolName2, modifierFlags) {
53837
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53838
+ context.approximateLength += 14 + internalSymbolName.length;
53465
53839
  const interfaceType = getDeclaredTypeOfClassOrInterface(symbol);
53466
53840
  const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
53467
53841
  const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
53468
53842
  const baseTypes = getBaseTypes(interfaceType);
53469
53843
  const baseType = length(baseTypes) ? getIntersectionType(baseTypes) : void 0;
53470
- const members = flatMap(getPropertiesOfType(interfaceType), (p) => serializePropertySymbolForInterface(p, baseType));
53844
+ const members = serializePropertySymbolsForClassOrInterface(
53845
+ getPropertiesOfType(interfaceType),
53846
+ /*isClass*/
53847
+ false,
53848
+ baseType
53849
+ );
53471
53850
  const callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 179 /* CallSignature */);
53472
53851
  const constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 180 /* ConstructSignature */);
53473
53852
  const indexSignatures = serializeIndexSignatures(interfaceType, baseType);
@@ -53476,7 +53855,7 @@ function createTypeChecker(host) {
53476
53855
  factory.createInterfaceDeclaration(
53477
53856
  /*modifiers*/
53478
53857
  void 0,
53479
- getInternalSymbolName(symbol, symbolName2),
53858
+ internalSymbolName,
53480
53859
  typeParamDecls,
53481
53860
  heritageClauses,
53482
53861
  [...indexSignatures, ...constructSignatures, ...callSignatures, ...members]
@@ -53484,6 +53863,57 @@ function createTypeChecker(host) {
53484
53863
  modifierFlags
53485
53864
  );
53486
53865
  }
53866
+ function serializePropertySymbolsForClassOrInterface(props, isClass, baseType, isStatic2) {
53867
+ const elements = [];
53868
+ let i = 0;
53869
+ for (const prop of props) {
53870
+ i++;
53871
+ if (checkTruncationLengthIfExpanding(context) && i + 2 < props.length - 1) {
53872
+ context.out.truncated = true;
53873
+ const placeholder = createTruncationProperty(`... ${props.length - i} more ... `, isClass);
53874
+ elements.push(placeholder);
53875
+ const result2 = isClass ? serializePropertySymbolForClass(props[props.length - 1], isStatic2, baseType) : serializePropertySymbolForInterface(props[props.length - 1], baseType);
53876
+ if (isArray(result2)) {
53877
+ elements.push(...result2);
53878
+ } else {
53879
+ elements.push(result2);
53880
+ }
53881
+ break;
53882
+ }
53883
+ context.approximateLength += 1;
53884
+ const result = isClass ? serializePropertySymbolForClass(prop, isStatic2, baseType) : serializePropertySymbolForInterface(prop, baseType);
53885
+ if (isArray(result)) {
53886
+ elements.push(...result);
53887
+ } else {
53888
+ elements.push(result);
53889
+ }
53890
+ }
53891
+ return elements;
53892
+ }
53893
+ function createTruncationProperty(dotDotDotText, isClass) {
53894
+ if (context.flags & 1 /* NoTruncation */) {
53895
+ return addSyntheticLeadingComment(factory.createNotEmittedTypeElement(), 3 /* MultiLineCommentTrivia */, dotDotDotText);
53896
+ }
53897
+ return isClass ? factory.createPropertyDeclaration(
53898
+ /*modifiers*/
53899
+ void 0,
53900
+ dotDotDotText,
53901
+ /*questionOrExclamationToken*/
53902
+ void 0,
53903
+ /*type*/
53904
+ void 0,
53905
+ /*initializer*/
53906
+ void 0
53907
+ ) : factory.createPropertySignature(
53908
+ /*modifiers*/
53909
+ void 0,
53910
+ dotDotDotText,
53911
+ /*questionToken*/
53912
+ void 0,
53913
+ /*type*/
53914
+ void 0
53915
+ );
53916
+ }
53487
53917
  function getNamespaceMembersForSerialization(symbol) {
53488
53918
  let exports2 = arrayFrom(getExportsOfSymbol(symbol).values());
53489
53919
  const merged = getMergedSymbol(symbol);
@@ -53503,11 +53933,27 @@ function createTypeChecker(host) {
53503
53933
  }
53504
53934
  function serializeModule(symbol, symbolName2, modifierFlags) {
53505
53935
  const members = getNamespaceMembersForSerialization(symbol);
53506
- const locationMap = arrayToMultiMap(members, (m) => m.parent && m.parent === symbol ? "real" : "merged");
53936
+ const expanding = isExpanding(context);
53937
+ const locationMap = arrayToMultiMap(members, (m) => m.parent && m.parent === symbol || expanding ? "real" : "merged");
53507
53938
  const realMembers = locationMap.get("real") || emptyArray;
53508
53939
  const mergedMembers = locationMap.get("merged") || emptyArray;
53509
- if (length(realMembers)) {
53510
- const localName = getInternalSymbolName(symbol, symbolName2);
53940
+ if (length(realMembers) || expanding) {
53941
+ let localName;
53942
+ if (expanding) {
53943
+ const oldFlags = context.flags;
53944
+ context.flags |= 512 /* WriteTypeParametersInQualifiedName */ | 2 /* UseOnlyExternalAliasing */;
53945
+ localName = symbolToNode(
53946
+ symbol,
53947
+ context,
53948
+ /*meaning*/
53949
+ -1 /* All */
53950
+ );
53951
+ context.flags = oldFlags;
53952
+ } else {
53953
+ const localText = getInternalSymbolName(symbol, symbolName2);
53954
+ localName = factory.createIdentifier(localText);
53955
+ context.approximateLength += localText.length;
53956
+ }
53511
53957
  serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */)));
53512
53958
  }
53513
53959
  if (length(mergedMembers)) {
@@ -53555,17 +54001,51 @@ function createTypeChecker(host) {
53555
54001
  }
53556
54002
  }
53557
54003
  function serializeEnum(symbol, symbolName2, modifierFlags) {
54004
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
54005
+ context.approximateLength += 9 + internalSymbolName.length;
54006
+ const members = [];
54007
+ const memberProps = filter(getPropertiesOfType(getTypeOfSymbol(symbol)), (p) => !!(p.flags & 8 /* EnumMember */));
54008
+ let i = 0;
54009
+ for (const p of memberProps) {
54010
+ i++;
54011
+ if (checkTruncationLengthIfExpanding(context) && i + 2 < memberProps.length - 1) {
54012
+ context.out.truncated = true;
54013
+ members.push(factory.createEnumMember(` ... ${memberProps.length - i} more ... `));
54014
+ const last2 = memberProps[memberProps.length - 1];
54015
+ const initializedValue = last2.declarations && last2.declarations[0] && isEnumMember(last2.declarations[0]) ? getConstantValue2(last2.declarations[0]) : void 0;
54016
+ const initializer2 = initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue);
54017
+ const memberName2 = unescapeLeadingUnderscores(last2.escapedName);
54018
+ const member2 = factory.createEnumMember(
54019
+ memberName2,
54020
+ initializer2
54021
+ );
54022
+ members.push(member2);
54023
+ break;
54024
+ }
54025
+ const memberDecl = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? p.declarations[0] : void 0;
54026
+ let initializer;
54027
+ let initializerLength;
54028
+ if (isExpanding(context) && memberDecl && memberDecl.initializer) {
54029
+ initializer = getSynthesizedDeepClone(memberDecl.initializer);
54030
+ initializerLength = memberDecl.initializer.end - memberDecl.initializer.pos;
54031
+ } else {
54032
+ const initializedValue = memberDecl && getConstantValue2(memberDecl);
54033
+ initializer = initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue);
54034
+ initializerLength = (initializer == null ? void 0 : initializer.text.length) ?? 0;
54035
+ }
54036
+ const memberName = unescapeLeadingUnderscores(p.escapedName);
54037
+ context.approximateLength += 4 + memberName.length + initializerLength;
54038
+ const member = factory.createEnumMember(
54039
+ memberName,
54040
+ initializer
54041
+ );
54042
+ members.push(member);
54043
+ }
53558
54044
  addResult(
53559
54045
  factory.createEnumDeclaration(
53560
54046
  factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 4096 /* Const */ : 0),
53561
- getInternalSymbolName(symbol, symbolName2),
53562
- map(filter(getPropertiesOfType(getTypeOfSymbol(symbol)), (p) => !!(p.flags & 8 /* EnumMember */)), (p) => {
53563
- const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? getConstantValue2(p.declarations[0]) : void 0;
53564
- return factory.createEnumMember(
53565
- unescapeLeadingUnderscores(p.escapedName),
53566
- initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue)
53567
- );
53568
- })
54047
+ internalSymbolName,
54048
+ members
53569
54049
  ),
53570
54050
  modifierFlags
53571
54051
  );
@@ -53573,20 +54053,28 @@ function createTypeChecker(host) {
53573
54053
  function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
53574
54054
  const signatures = getSignaturesOfType(type, 0 /* Call */);
53575
54055
  for (const sig of signatures) {
54056
+ context.approximateLength += 1;
53576
54057
  const decl = signatureToSignatureDeclarationHelper(sig, 262 /* FunctionDeclaration */, context, { name: factory.createIdentifier(localName) });
53577
54058
  addResult(setTextRange2(context, decl, getSignatureTextRangeLocation(sig)), modifierFlags);
53578
54059
  }
53579
54060
  if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) {
53580
54061
  const props = filter(getPropertiesOfType(type), isNamespaceMember);
54062
+ context.approximateLength += localName.length;
53581
54063
  serializeAsNamespaceDeclaration(
53582
54064
  props,
53583
- localName,
54065
+ factory.createIdentifier(localName),
53584
54066
  modifierFlags,
53585
54067
  /*suppressNewPrivateContext*/
53586
54068
  true
53587
54069
  );
53588
54070
  }
53589
54071
  }
54072
+ function createTruncationStatement(dotDotDotText) {
54073
+ if (context.flags & 1 /* NoTruncation */) {
54074
+ return addSyntheticLeadingComment(factory.createEmptyStatement(), 3 /* MultiLineCommentTrivia */, dotDotDotText);
54075
+ }
54076
+ return factory.createExpressionStatement(factory.createIdentifier(dotDotDotText));
54077
+ }
53590
54078
  function getSignatureTextRangeLocation(signature) {
53591
54079
  if (signature.declaration && signature.declaration.parent) {
53592
54080
  if (isBinaryExpression(signature.declaration.parent) && getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) {
@@ -53599,15 +54087,18 @@ function createTypeChecker(host) {
53599
54087
  return signature.declaration;
53600
54088
  }
53601
54089
  function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) {
54090
+ const nodeFlags = isIdentifier(localName) ? 32 /* Namespace */ : 0 /* None */;
54091
+ const expanding = isExpanding(context);
53602
54092
  if (length(props)) {
53603
- const localVsRemoteMap = arrayToMultiMap(props, (p) => !length(p.declarations) || some(p.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)) ? "local" : "remote");
54093
+ context.approximateLength += 14;
54094
+ const localVsRemoteMap = arrayToMultiMap(props, (p) => !length(p.declarations) || some(p.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)) || expanding ? "local" : "remote");
53604
54095
  const localProps = localVsRemoteMap.get("local") || emptyArray;
53605
54096
  let fakespace = parseNodeFactory.createModuleDeclaration(
53606
54097
  /*modifiers*/
53607
54098
  void 0,
53608
- factory.createIdentifier(localName),
54099
+ localName,
53609
54100
  factory.createModuleBlock([]),
53610
- 32 /* Namespace */
54101
+ nodeFlags
53611
54102
  );
53612
54103
  setParent(fakespace, enclosingDeclaration);
53613
54104
  fakespace.locals = createSymbolTable(props);
@@ -53649,6 +54140,18 @@ function createTypeChecker(host) {
53649
54140
  factory.createModuleBlock(exportModifierStripped)
53650
54141
  );
53651
54142
  addResult(fakespace, modifierFlags);
54143
+ } else if (expanding) {
54144
+ context.approximateLength += 14;
54145
+ addResult(
54146
+ factory.createModuleDeclaration(
54147
+ /*modifiers*/
54148
+ void 0,
54149
+ localName,
54150
+ factory.createModuleBlock([]),
54151
+ nodeFlags
54152
+ ),
54153
+ modifierFlags
54154
+ );
53652
54155
  }
53653
54156
  }
53654
54157
  function isNamespaceMember(p) {
@@ -53691,11 +54194,13 @@ function createTypeChecker(host) {
53691
54194
  }
53692
54195
  function serializeAsClass(symbol, localName, modifierFlags) {
53693
54196
  var _a2, _b;
54197
+ context.approximateLength += 9 + localName.length;
53694
54198
  const originalDecl = (_a2 = symbol.declarations) == null ? void 0 : _a2.find(isClassLike);
53695
54199
  const oldEnclosing = context.enclosingDeclaration;
53696
54200
  context.enclosingDeclaration = originalDecl || oldEnclosing;
53697
54201
  const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
53698
54202
  const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
54203
+ forEach(localParams, (p) => context.approximateLength += symbolName(p.symbol).length);
53699
54204
  const classType = getTypeWithThisArgument(getDeclaredTypeOfClassOrInterface(symbol));
53700
54205
  const baseTypes = getBaseTypes(classType);
53701
54206
  const originalImplements = originalDecl && getEffectiveImplementsTypeNodes(originalDecl);
@@ -53703,20 +54208,22 @@ function createTypeChecker(host) {
53703
54208
  const staticType = getTypeOfSymbol(symbol);
53704
54209
  const isClass = !!((_b = staticType.symbol) == null ? void 0 : _b.valueDeclaration) && isClassLike(staticType.symbol.valueDeclaration);
53705
54210
  const staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType;
54211
+ context.approximateLength += (length(baseTypes) ? 8 : 0) + (length(implementsExpressions) ? 11 : 0);
53706
54212
  const heritageClauses = [
53707
54213
  ...!length(baseTypes) ? [] : [factory.createHeritageClause(96 /* ExtendsKeyword */, map(baseTypes, (b) => serializeBaseType(b, staticBaseType, localName)))],
53708
54214
  ...!length(implementsExpressions) ? [] : [factory.createHeritageClause(119 /* ImplementsKeyword */, implementsExpressions)]
53709
54215
  ];
53710
54216
  const symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType));
53711
- const publicSymbolProps = filter(symbolProps, (s) => {
53712
- const valueDecl = s.valueDeclaration;
53713
- return !!valueDecl && !(isNamedDeclaration(valueDecl) && isPrivateIdentifier(valueDecl.name));
53714
- });
53715
- const hasPrivateIdentifier = some(symbolProps, (s) => {
53716
- const valueDecl = s.valueDeclaration;
53717
- return !!valueDecl && isNamedDeclaration(valueDecl) && isPrivateIdentifier(valueDecl.name);
53718
- });
53719
- const privateProperties = hasPrivateIdentifier ? [factory.createPropertyDeclaration(
54217
+ const publicSymbolProps = filter(symbolProps, (s) => !isHashPrivate(s));
54218
+ const hasPrivateIdentifier = some(symbolProps, isHashPrivate);
54219
+ const privateProperties = hasPrivateIdentifier ? isExpanding(context) ? serializePropertySymbolsForClassOrInterface(
54220
+ filter(symbolProps, isHashPrivate),
54221
+ /*isClass*/
54222
+ true,
54223
+ baseTypes[0],
54224
+ /*isStatic*/
54225
+ false
54226
+ ) : [factory.createPropertyDeclaration(
53720
54227
  /*modifiers*/
53721
54228
  void 0,
53722
54229
  factory.createPrivateIdentifier("#private"),
@@ -53727,22 +54234,27 @@ function createTypeChecker(host) {
53727
54234
  /*initializer*/
53728
54235
  void 0
53729
54236
  )] : emptyArray;
53730
- const publicProperties = flatMap(publicSymbolProps, (p) => serializePropertySymbolForClass(
53731
- p,
54237
+ if (hasPrivateIdentifier && !isExpanding(context)) {
54238
+ context.approximateLength += 9;
54239
+ }
54240
+ const publicProperties = serializePropertySymbolsForClassOrInterface(
54241
+ publicSymbolProps,
54242
+ /*isClass*/
54243
+ true,
54244
+ baseTypes[0],
53732
54245
  /*isStatic*/
53733
- false,
53734
- baseTypes[0]
53735
- ));
53736
- const staticMembers = flatMap(
54246
+ false
54247
+ );
54248
+ const staticMembers = serializePropertySymbolsForClassOrInterface(
53737
54249
  filter(getPropertiesOfType(staticType), (p) => !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p)),
53738
- (p) => serializePropertySymbolForClass(
53739
- p,
53740
- /*isStatic*/
53741
- true,
53742
- staticBaseType
53743
- )
54250
+ /*isClass*/
54251
+ true,
54252
+ staticBaseType,
54253
+ /*isStatic*/
54254
+ true
53744
54255
  );
53745
54256
  const isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && !some(getSignaturesOfType(staticType, 1 /* Construct */));
54257
+ if (isNonConstructableClassLikeInJsFile) context.approximateLength += 21;
53746
54258
  const constructors = isNonConstructableClassLikeInJsFile ? [factory.createConstructorDeclaration(
53747
54259
  factory.createModifiersFromModifierFlags(2 /* Private */),
53748
54260
  [],
@@ -53810,6 +54322,8 @@ function createTypeChecker(host) {
53810
54322
  if (((_b = (_a2 = node.parent) == null ? void 0 : _a2.parent) == null ? void 0 : _b.kind) === 260 /* VariableDeclaration */) {
53811
54323
  const specifier2 = getSpecifierForModuleSymbol(target.parent || target, context);
53812
54324
  const { propertyName } = node;
54325
+ const propertyNameText = propertyName && isIdentifier(propertyName) ? idText(propertyName) : void 0;
54326
+ context.approximateLength += 24 + localName.length + specifier2.length + ((propertyNameText == null ? void 0 : propertyNameText.length) ?? 0);
53813
54327
  addResult(
53814
54328
  factory.createImportDeclaration(
53815
54329
  /*modifiers*/
@@ -53822,7 +54336,7 @@ function createTypeChecker(host) {
53822
54336
  factory.createNamedImports([factory.createImportSpecifier(
53823
54337
  /*isTypeOnly*/
53824
54338
  false,
53825
- propertyName && isIdentifier(propertyName) ? factory.createIdentifier(idText(propertyName)) : void 0,
54339
+ propertyNameText ? factory.createIdentifier(propertyNameText) : void 0,
53826
54340
  factory.createIdentifier(localName)
53827
54341
  )])
53828
54342
  ),
@@ -53849,6 +54363,7 @@ function createTypeChecker(host) {
53849
54363
  const initializer = node.initializer;
53850
54364
  const uniqueName = factory.createUniqueName(localName);
53851
54365
  const specifier2 = getSpecifierForModuleSymbol(target.parent || target, context);
54366
+ context.approximateLength += 22 + specifier2.length + idText(uniqueName).length;
53852
54367
  addResult(
53853
54368
  factory.createImportEqualsDeclaration(
53854
54369
  /*modifiers*/
@@ -53860,6 +54375,7 @@ function createTypeChecker(host) {
53860
54375
  ),
53861
54376
  0 /* None */
53862
54377
  );
54378
+ context.approximateLength += 12 + localName.length + idText(uniqueName).length + idText(initializer.name).length;
53863
54379
  addResult(
53864
54380
  factory.createImportEqualsDeclaration(
53865
54381
  /*modifiers*/
@@ -53880,6 +54396,7 @@ function createTypeChecker(host) {
53880
54396
  break;
53881
54397
  }
53882
54398
  const isLocalImport = !(target.flags & 512 /* ValueModule */) && !isVariableDeclaration(node);
54399
+ context.approximateLength += 11 + localName.length + unescapeLeadingUnderscores(target.escapedName).length;
53883
54400
  addResult(
53884
54401
  factory.createImportEqualsDeclaration(
53885
54402
  /*modifiers*/
@@ -53906,6 +54423,7 @@ function createTypeChecker(host) {
53906
54423
  const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
53907
54424
  const attributes = isImportDeclaration(node.parent) ? node.parent.attributes : void 0;
53908
54425
  const isTypeOnly = isJSDocImportTag(node.parent);
54426
+ context.approximateLength += 14 + localName.length + 3 + (isTypeOnly ? 4 : 0);
53909
54427
  addResult(
53910
54428
  factory.createImportDeclaration(
53911
54429
  /*modifiers*/
@@ -53927,6 +54445,7 @@ function createTypeChecker(host) {
53927
54445
  const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
53928
54446
  const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
53929
54447
  const isTypeOnly = isJSDocImportTag(node.parent.parent);
54448
+ context.approximateLength += 19 + localName.length + 3 + (isTypeOnly ? 4 : 0);
53930
54449
  addResult(
53931
54450
  factory.createImportDeclaration(
53932
54451
  /*modifiers*/
@@ -53945,6 +54464,7 @@ function createTypeChecker(host) {
53945
54464
  break;
53946
54465
  }
53947
54466
  case 280 /* NamespaceExport */:
54467
+ context.approximateLength += 19 + localName.length + 3;
53948
54468
  addResult(
53949
54469
  factory.createExportDeclaration(
53950
54470
  /*modifiers*/
@@ -53961,6 +54481,7 @@ function createTypeChecker(host) {
53961
54481
  const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
53962
54482
  const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
53963
54483
  const isTypeOnly = isJSDocImportTag(node.parent.parent.parent);
54484
+ context.approximateLength += 19 + localName.length + 3 + (isTypeOnly ? 4 : 0);
53964
54485
  addResult(
53965
54486
  factory.createImportDeclaration(
53966
54487
  /*modifiers*/
@@ -54016,6 +54537,7 @@ function createTypeChecker(host) {
54016
54537
  }
54017
54538
  }
54018
54539
  function serializeExportSpecifier(localName, targetName, specifier) {
54540
+ context.approximateLength += 16 + localName.length + (localName !== targetName ? targetName.length : 0);
54019
54541
  addResult(
54020
54542
  factory.createExportDeclaration(
54021
54543
  /*modifiers*/
@@ -54066,6 +54588,7 @@ function createTypeChecker(host) {
54066
54588
  const prevDisableTrackSymbol = context.tracker.disableTrackSymbol;
54067
54589
  context.tracker.disableTrackSymbol = true;
54068
54590
  if (isExportAssignmentCompatibleSymbolName) {
54591
+ context.approximateLength += 10;
54069
54592
  results.push(factory.createExportAssignment(
54070
54593
  /*modifiers*/
54071
54594
  void 0,
@@ -54079,6 +54602,7 @@ function createTypeChecker(host) {
54079
54602
  serializeExportSpecifier(name, getInternalSymbolName(target, symbolName(target)));
54080
54603
  } else {
54081
54604
  const varName = getUnusedName(name, symbol);
54605
+ context.approximateLength += varName.length + 10;
54082
54606
  addResult(
54083
54607
  factory.createImportEqualsDeclaration(
54084
54608
  /*modifiers*/
@@ -54108,6 +54632,7 @@ function createTypeChecker(host) {
54108
54632
  serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 32 /* Export */);
54109
54633
  } else {
54110
54634
  const flags = ((_a2 = context.enclosingDeclaration) == null ? void 0 : _a2.kind) === 267 /* ModuleDeclaration */ && (!(symbol.flags & 98304 /* Accessor */) || symbol.flags & 65536 /* SetAccessor */) ? 1 /* Let */ : 2 /* Const */;
54635
+ context.approximateLength += varName.length + 5;
54111
54636
  const statement = factory.createVariableStatement(
54112
54637
  /*modifiers*/
54113
54638
  void 0,
@@ -54132,6 +54657,7 @@ function createTypeChecker(host) {
54132
54657
  );
54133
54658
  }
54134
54659
  if (isExportAssignmentCompatibleSymbolName) {
54660
+ context.approximateLength += varName.length + 10;
54135
54661
  results.push(factory.createExportAssignment(
54136
54662
  /*modifiers*/
54137
54663
  void 0,
@@ -54166,7 +54692,7 @@ function createTypeChecker(host) {
54166
54692
  return function serializePropertySymbol(p, isStatic2, baseType) {
54167
54693
  var _a2, _b, _c, _d, _e, _f;
54168
54694
  const modifierFlags = getDeclarationModifierFlagsFromSymbol(p);
54169
- const isPrivate = !!(modifierFlags & 2 /* Private */);
54695
+ const omitType = !!(modifierFlags & 2 /* Private */) && !isExpanding(context);
54170
54696
  if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) {
54171
54697
  return [];
54172
54698
  }
@@ -54195,6 +54721,7 @@ function createTypeChecker(host) {
54195
54721
  Debug.assert(!!setter);
54196
54722
  const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : void 0;
54197
54723
  const setterDeclaration = (_b = p.declarations) == null ? void 0 : _b.find(isSetAccessor);
54724
+ context.approximateLength += modifiersLength(flag) + 7 + (paramSymbol ? symbolName(paramSymbol).length : 5) + (omitType ? 0 : 2);
54198
54725
  result.push(setTextRange2(
54199
54726
  context,
54200
54727
  factory.createSetAccessorDeclaration(
@@ -54208,7 +54735,7 @@ function createTypeChecker(host) {
54208
54735
  paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
54209
54736
  /*questionToken*/
54210
54737
  void 0,
54211
- isPrivate ? void 0 : serializeTypeForDeclaration(context, setterDeclaration, getWriteTypeOfSymbol(p), p)
54738
+ omitType ? void 0 : serializeTypeForDeclaration(context, setterDeclaration, getWriteTypeOfSymbol(p), p)
54212
54739
  )],
54213
54740
  /*body*/
54214
54741
  void 0
@@ -54217,15 +54744,15 @@ function createTypeChecker(host) {
54217
54744
  ));
54218
54745
  }
54219
54746
  if (p.flags & 32768 /* GetAccessor */) {
54220
- const isPrivate2 = modifierFlags & 2 /* Private */;
54221
54747
  const getterDeclaration = (_c = p.declarations) == null ? void 0 : _c.find(isGetAccessor);
54748
+ context.approximateLength += modifiersLength(flag) + 8 + (omitType ? 0 : 2);
54222
54749
  result.push(setTextRange2(
54223
54750
  context,
54224
54751
  factory.createGetAccessorDeclaration(
54225
54752
  factory.createModifiersFromModifierFlags(flag),
54226
54753
  name,
54227
54754
  [],
54228
- isPrivate2 ? void 0 : serializeTypeForDeclaration(context, getterDeclaration, getTypeOfSymbol(p), p),
54755
+ omitType ? void 0 : serializeTypeForDeclaration(context, getterDeclaration, getTypeOfSymbol(p), p),
54229
54756
  /*body*/
54230
54757
  void 0
54231
54758
  ),
@@ -54234,13 +54761,15 @@ function createTypeChecker(host) {
54234
54761
  }
54235
54762
  return result;
54236
54763
  } else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) {
54764
+ const modifierFlags2 = (isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag;
54765
+ context.approximateLength += 2 + (omitType ? 0 : 2) + modifiersLength(modifierFlags2);
54237
54766
  return setTextRange2(
54238
54767
  context,
54239
54768
  createProperty2(
54240
- factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
54769
+ factory.createModifiersFromModifierFlags(modifierFlags2),
54241
54770
  name,
54242
54771
  p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
54243
- isPrivate ? void 0 : serializeTypeForDeclaration(context, (_d = p.declarations) == null ? void 0 : _d.find(isSetAccessorDeclaration), getWriteTypeOfSymbol(p), p),
54772
+ omitType ? void 0 : serializeTypeForDeclaration(context, (_d = p.declarations) == null ? void 0 : _d.find(isSetAccessorDeclaration), getWriteTypeOfSymbol(p), p),
54244
54773
  // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357
54245
54774
  // interface members can't have initializers, however class members _can_
54246
54775
  /*initializer*/
@@ -54252,11 +54781,13 @@ function createTypeChecker(host) {
54252
54781
  if (p.flags & (8192 /* Method */ | 16 /* Function */)) {
54253
54782
  const type = getTypeOfSymbol(p);
54254
54783
  const signatures = getSignaturesOfType(type, 0 /* Call */);
54255
- if (flag & 2 /* Private */) {
54784
+ if (omitType) {
54785
+ const modifierFlags2 = (isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag;
54786
+ context.approximateLength += 1 + modifiersLength(modifierFlags2);
54256
54787
  return setTextRange2(
54257
54788
  context,
54258
54789
  createProperty2(
54259
- factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
54790
+ factory.createModifiersFromModifierFlags(modifierFlags2),
54260
54791
  name,
54261
54792
  p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
54262
54793
  /*type*/
@@ -54269,6 +54800,7 @@ function createTypeChecker(host) {
54269
54800
  }
54270
54801
  const results2 = [];
54271
54802
  for (const sig of signatures) {
54803
+ context.approximateLength += 1;
54272
54804
  const decl = signatureToSignatureDeclarationHelper(
54273
54805
  sig,
54274
54806
  methodKind,
@@ -54287,6 +54819,25 @@ function createTypeChecker(host) {
54287
54819
  return Debug.fail(`Unhandled class member kind! ${p.__debugFlags || p.flags}`);
54288
54820
  };
54289
54821
  }
54822
+ function modifiersLength(flags) {
54823
+ let result = 0;
54824
+ if (flags & 32 /* Export */) result += 7;
54825
+ if (flags & 128 /* Ambient */) result += 8;
54826
+ if (flags & 2048 /* Default */) result += 8;
54827
+ if (flags & 4096 /* Const */) result += 6;
54828
+ if (flags & 1 /* Public */) result += 7;
54829
+ if (flags & 2 /* Private */) result += 8;
54830
+ if (flags & 4 /* Protected */) result += 10;
54831
+ if (flags & 64 /* Abstract */) result += 9;
54832
+ if (flags & 256 /* Static */) result += 7;
54833
+ if (flags & 16 /* Override */) result += 9;
54834
+ if (flags & 8 /* Readonly */) result += 9;
54835
+ if (flags & 512 /* Accessor */) result += 9;
54836
+ if (flags & 1024 /* Async */) result += 6;
54837
+ if (flags & 8192 /* In */) result += 3;
54838
+ if (flags & 16384 /* Out */) result += 4;
54839
+ return result;
54840
+ }
54290
54841
  function serializePropertySymbolForInterface(p, baseType) {
54291
54842
  return serializePropertySymbolForInterfaceWorker(
54292
54843
  p,
@@ -54351,6 +54902,7 @@ function createTypeChecker(host) {
54351
54902
  }
54352
54903
  const results2 = [];
54353
54904
  for (const sig of signatures) {
54905
+ context.approximateLength += 1;
54354
54906
  const decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
54355
54907
  results2.push(setTextRange2(context, decl, sig.declaration));
54356
54908
  }
@@ -54476,6 +55028,23 @@ function createTypeChecker(host) {
54476
55028
  return localName;
54477
55029
  }
54478
55030
  }
55031
+ function isExpanding(context) {
55032
+ return context.maxExpansionDepth !== -1;
55033
+ }
55034
+ function isHashPrivate(s) {
55035
+ return !!s.valueDeclaration && isNamedDeclaration(s.valueDeclaration) && isPrivateIdentifier(s.valueDeclaration.name);
55036
+ }
55037
+ function getClonedHashPrivateName(s) {
55038
+ if (s.valueDeclaration && isNamedDeclaration(s.valueDeclaration) && isPrivateIdentifier(s.valueDeclaration.name)) {
55039
+ return factory.cloneNode(s.valueDeclaration.name);
55040
+ }
55041
+ return void 0;
55042
+ }
55043
+ }
55044
+ function isLibType(type) {
55045
+ var _a;
55046
+ const symbol = (getObjectFlags(type) & 4 /* Reference */) !== 0 ? type.target.symbol : type.symbol;
55047
+ return isTupleType(type) || !!((_a = symbol == null ? void 0 : symbol.declarations) == null ? void 0 : _a.some((decl) => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl))));
54479
55048
  }
54480
55049
  function typePredicateToString(typePredicate, enclosingDeclaration, flags = 16384 /* UseAliasDefinedOutsideCurrentScope */, writer) {
54481
55050
  return writer ? typePredicateToStringWorker(writer).getText() : usingSingleLineStringWriter(typePredicateToStringWorker);
@@ -54494,14 +55063,14 @@ function createTypeChecker(host) {
54494
55063
  return writer2;
54495
55064
  }
54496
55065
  }
54497
- function formatUnionTypes(types) {
55066
+ function formatUnionTypes(types, expandingEnum) {
54498
55067
  const result = [];
54499
55068
  let flags = 0;
54500
55069
  for (let i = 0; i < types.length; i++) {
54501
55070
  const t = types[i];
54502
55071
  flags |= t.flags;
54503
55072
  if (!(t.flags & 98304 /* Nullable */)) {
54504
- if (t.flags & (512 /* BooleanLiteral */ | 1056 /* EnumLike */)) {
55073
+ if (t.flags & 512 /* BooleanLiteral */ || !expandingEnum && t.flags | 1056 /* EnumLike */) {
54505
55074
  const baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLikeType(t);
54506
55075
  if (baseType.flags & 1048576 /* Union */) {
54507
55076
  const count = baseType.types.length;
@@ -58584,7 +59153,7 @@ function createTypeChecker(host) {
58584
59153
  let hasThisParameter = false;
58585
59154
  const iife = getImmediatelyInvokedFunctionExpression(declaration);
58586
59155
  const isJSConstructSignature = isJSDocConstructSignature(declaration);
58587
- const isUntypedSignatureInJSFile = !iife && isInJSFile(declaration) && isValueSignatureDeclaration(declaration) && !hasJSDocParameterTags(declaration) && !getJSDocType(declaration) && !getContextualSignatureForFunctionLikeDeclaration(declaration);
59156
+ const isUntypedSignatureInJSFile = !iife && isInJSFile(declaration) && isValueSignatureDeclaration(declaration) && !hasJSDocParameterTags(declaration) && !some(declaration.parameters, (p) => !!getJSDocType(p)) && !getJSDocType(declaration) && !getContextualSignatureForFunctionLikeDeclaration(declaration);
58588
59157
  if (isUntypedSignatureInJSFile) {
58589
59158
  flags |= 32 /* IsUntypedSignatureInJSFile */;
58590
59159
  }
@@ -62707,7 +63276,7 @@ function createTypeChecker(host) {
62707
63276
  ) : type;
62708
63277
  }
62709
63278
  function instantiateTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
62710
- var _a, _b;
63279
+ var _a;
62711
63280
  if (!couldContainTypeVariables(type)) {
62712
63281
  return type;
62713
63282
  }
@@ -62716,8 +63285,13 @@ function createTypeChecker(host) {
62716
63285
  error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
62717
63286
  return errorType;
62718
63287
  }
63288
+ const index = findActiveMapper(mapper);
63289
+ if (index === -1) {
63290
+ pushActiveMapper(mapper);
63291
+ }
62719
63292
  const key = type.id + getAliasId(aliasSymbol, aliasTypeArguments);
62720
- const cached = (mapper.instantiations ?? (mapper.instantiations = /* @__PURE__ */ new Map())).get(key);
63293
+ const mapperCache = activeTypeMappersCaches[index !== -1 ? index : activeTypeMappersCount - 1];
63294
+ const cached = mapperCache.get(key);
62721
63295
  if (cached) {
62722
63296
  return cached;
62723
63297
  }
@@ -62725,7 +63299,11 @@ function createTypeChecker(host) {
62725
63299
  instantiationCount++;
62726
63300
  instantiationDepth++;
62727
63301
  const result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments);
62728
- (_b = mapper.instantiations) == null ? void 0 : _b.set(key, result);
63302
+ if (index === -1) {
63303
+ popActiveMapper();
63304
+ } else {
63305
+ mapperCache.set(key, result);
63306
+ }
62729
63307
  instantiationDepth--;
62730
63308
  return result;
62731
63309
  }
@@ -67245,7 +67823,7 @@ function createTypeChecker(host) {
67245
67823
  }
67246
67824
  function clearCachedInferences(context, inferences) {
67247
67825
  if (context) {
67248
- context.nonFixingMapper.instantiations = void 0;
67826
+ clearActiveMapperCache(context.nonFixingMapper);
67249
67827
  }
67250
67828
  for (const inference of inferences) {
67251
67829
  if (!inference.isFixed) {
@@ -68279,7 +68857,7 @@ function createTypeChecker(host) {
68279
68857
  const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
68280
68858
  if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
68281
68859
  inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
68282
- context.nonFixingMapper.instantiations = void 0;
68860
+ clearActiveMapperCache(context.nonFixingMapper);
68283
68861
  }
68284
68862
  }
68285
68863
  }
@@ -72543,6 +73121,28 @@ function createTypeChecker(host) {
72543
73121
  }
72544
73122
  }
72545
73123
  }
73124
+ function pushActiveMapper(mapper) {
73125
+ activeTypeMappers[activeTypeMappersCount] = mapper;
73126
+ activeTypeMappersCaches[activeTypeMappersCount] = /* @__PURE__ */ new Map();
73127
+ activeTypeMappersCount++;
73128
+ }
73129
+ function popActiveMapper() {
73130
+ activeTypeMappersCount--;
73131
+ }
73132
+ function findActiveMapper(mapper) {
73133
+ for (let i = activeTypeMappersCount - 1; i >= 0; i--) {
73134
+ if (mapper === activeTypeMappers[i]) {
73135
+ return i;
73136
+ }
73137
+ }
73138
+ return -1;
73139
+ }
73140
+ function clearActiveMapperCache(mapper) {
73141
+ const index = findActiveMapper(mapper);
73142
+ if (index !== -1) {
73143
+ activeTypeMappersCaches[index] = /* @__PURE__ */ new Map();
73144
+ }
73145
+ }
72546
73146
  function getContextualImportAttributeType(node) {
72547
73147
  return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
72548
73148
  /*reportErrors*/
@@ -87463,6 +88063,9 @@ function createTypeChecker(host) {
87463
88063
  tracker.trackSymbol(name, enclosing, 111551 /* Value */);
87464
88064
  }
87465
88065
  }
88066
+ },
88067
+ symbolToDeclarations: (symbol, meaning, flags, verbosityLevel, out) => {
88068
+ return nodeBuilder.symbolToDeclarations(symbol, meaning, flags, verbosityLevel, out);
87466
88069
  }
87467
88070
  };
87468
88071
  function isImportRequiredByAugmentation(node) {
@@ -115366,7 +115969,8 @@ var notImplementedResolver = {
115366
115969
  getDeclarationStatementsForSourceFile: notImplemented,
115367
115970
  isImportRequiredByAugmentation: notImplemented,
115368
115971
  isDefinitelyReferenceToGlobalSymbolObject: notImplemented,
115369
- createLateBoundIndexSignatures: notImplemented
115972
+ createLateBoundIndexSignatures: notImplemented,
115973
+ symbolToDeclarations: notImplemented
115370
115974
  };
115371
115975
  var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
115372
115976
  var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));