typescript 5.9.0-dev.20250415 → 5.9.0-dev.20250417

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,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.9";
21
- var version = `${versionMajorMinor}.0-dev.20250415`;
21
+ var version = `${versionMajorMinor}.0-dev.20250417`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -20013,6 +20013,82 @@ function getOptionsSyntaxByValue(optionsObject, name, value) {
20013
20013
  function forEachOptionsSyntaxByName(optionsObject, name, callback) {
20014
20014
  return forEachPropertyAssignment(optionsObject, name, callback);
20015
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
+ }
20016
20092
 
20017
20093
  // src/compiler/factory/baseNodeFactory.ts
20018
20094
  function createBaseNodeFactory() {
@@ -46376,11 +46452,11 @@ function createTypeChecker(host) {
46376
46452
  typePredicateToString: (predicate, enclosingDeclaration, flags) => {
46377
46453
  return typePredicateToString(predicate, getParseTreeNode(enclosingDeclaration), flags);
46378
46454
  },
46379
- writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => {
46380
- 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);
46381
46457
  },
46382
- writeType: (type, enclosingDeclaration, flags, writer) => {
46383
- 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);
46384
46460
  },
46385
46461
  writeSymbol: (symbol, enclosingDeclaration, meaning, flags, writer) => {
46386
46462
  return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
@@ -46614,7 +46690,8 @@ function createTypeChecker(host) {
46614
46690
  isTypeParameterPossiblyReferenced,
46615
46691
  typeHasCallOrConstructSignatures,
46616
46692
  getSymbolFlags,
46617
- getTypeArgumentsForResolvedSignature
46693
+ getTypeArgumentsForResolvedSignature,
46694
+ isLibType
46618
46695
  };
46619
46696
  function getTypeArgumentsForResolvedSignature(signature) {
46620
46697
  if (signature.mapper === void 0) return void 0;
@@ -50291,7 +50368,7 @@ function createTypeChecker(host) {
50291
50368
  return writer2;
50292
50369
  }
50293
50370
  }
50294
- function signatureToString(signature, enclosingDeclaration, flags = 0 /* None */, kind, writer) {
50371
+ function signatureToString(signature, enclosingDeclaration, flags = 0 /* None */, kind, writer, verbosityLevel, out) {
50295
50372
  return writer ? signatureToStringWorker(writer).getText() : usingSingleLineStringWriter(signatureToStringWorker);
50296
50373
  function signatureToStringWorker(writer2) {
50297
50374
  let sigOutput;
@@ -50300,7 +50377,18 @@ function createTypeChecker(host) {
50300
50377
  } else {
50301
50378
  sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructSignature */ : 179 /* CallSignature */;
50302
50379
  }
50303
- const sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */);
50380
+ const sig = nodeBuilder.signatureToSignatureDeclaration(
50381
+ signature,
50382
+ sigOutput,
50383
+ enclosingDeclaration,
50384
+ toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */,
50385
+ /*internalFlags*/
50386
+ void 0,
50387
+ /*tracker*/
50388
+ void 0,
50389
+ verbosityLevel,
50390
+ out
50391
+ );
50304
50392
  const printer = createPrinterWithRemoveCommentsOmitTrailingSemicolon();
50305
50393
  const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration);
50306
50394
  printer.writeNode(
@@ -50313,14 +50401,18 @@ function createTypeChecker(host) {
50313
50401
  return writer2;
50314
50402
  }
50315
50403
  }
50316
- function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter("")) {
50404
+ function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter(""), verbosityLevel, out) {
50317
50405
  const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */;
50318
50406
  const typeNode = nodeBuilder.typeToTypeNode(
50319
50407
  type,
50320
50408
  enclosingDeclaration,
50321
- toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0 /* None */),
50409
+ toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0),
50322
50410
  /*internalFlags*/
50323
- void 0
50411
+ void 0,
50412
+ /*tracker*/
50413
+ void 0,
50414
+ verbosityLevel,
50415
+ out
50324
50416
  );
50325
50417
  if (typeNode === void 0) return Debug.fail("should always get typenode");
50326
50418
  const printer = type !== unresolvedType ? createPrinterWithRemoveComments() : createPrinterWithDefaults();
@@ -50399,7 +50491,6 @@ function createTypeChecker(host) {
50399
50491
  },
50400
50492
  isOptionalParameter,
50401
50493
  isUndefinedIdentifierExpression(node) {
50402
- Debug.assert(isExpressionNode(node));
50403
50494
  return getSymbolAtLocation(node) === undefinedSymbol;
50404
50495
  },
50405
50496
  isEntityNameVisible(context, entityName, shouldComputeAliasToMakeVisible) {
@@ -50551,31 +50642,120 @@ function createTypeChecker(host) {
50551
50642
  };
50552
50643
  return {
50553
50644
  syntacticBuilderResolver,
50554
- typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeToTypeNodeHelper(type, context)),
50555
- typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
50556
- serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)),
50557
- serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)),
50558
- serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)),
50559
- indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
50560
- indexInfo,
50561
- context,
50562
- /*typeNode*/
50563
- void 0
50564
- )),
50565
- signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => signatureToSignatureDeclarationHelper(signature, kind, context)),
50566
- symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToName(
50567
- symbol,
50568
- context,
50569
- meaning,
50570
- /*expectsIdentifier*/
50571
- false
50572
- )),
50573
- symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToExpression(symbol, context, meaning)),
50574
- symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
50575
- symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
50576
- typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
50577
- symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
50578
- symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToNode(symbol, context, meaning))
50645
+ typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeToTypeNodeHelper(type, context), out),
50646
+ typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50647
+ enclosingDeclaration,
50648
+ flags,
50649
+ internalFlags,
50650
+ tracker,
50651
+ /*verbosityLevel*/
50652
+ void 0,
50653
+ (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)
50654
+ ),
50655
+ serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50656
+ enclosingDeclaration,
50657
+ flags,
50658
+ internalFlags,
50659
+ tracker,
50660
+ /*verbosityLevel*/
50661
+ void 0,
50662
+ (context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)
50663
+ ),
50664
+ serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50665
+ enclosingDeclaration,
50666
+ flags,
50667
+ internalFlags,
50668
+ tracker,
50669
+ /*verbosityLevel*/
50670
+ void 0,
50671
+ (context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)
50672
+ ),
50673
+ serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50674
+ enclosingDeclaration,
50675
+ flags,
50676
+ internalFlags,
50677
+ tracker,
50678
+ /*verbosityLevel*/
50679
+ void 0,
50680
+ (context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)
50681
+ ),
50682
+ indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50683
+ enclosingDeclaration,
50684
+ flags,
50685
+ internalFlags,
50686
+ tracker,
50687
+ /*verbosityLevel*/
50688
+ void 0,
50689
+ (context) => indexInfoToIndexSignatureDeclarationHelper(
50690
+ indexInfo,
50691
+ context,
50692
+ /*typeNode*/
50693
+ void 0
50694
+ )
50695
+ ),
50696
+ signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => signatureToSignatureDeclarationHelper(signature, kind, context), out),
50697
+ symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50698
+ enclosingDeclaration,
50699
+ flags,
50700
+ internalFlags,
50701
+ tracker,
50702
+ /*verbosityLevel*/
50703
+ void 0,
50704
+ (context) => symbolToName(
50705
+ symbol,
50706
+ context,
50707
+ meaning,
50708
+ /*expectsIdentifier*/
50709
+ false
50710
+ )
50711
+ ),
50712
+ symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50713
+ enclosingDeclaration,
50714
+ flags,
50715
+ internalFlags,
50716
+ tracker,
50717
+ /*verbosityLevel*/
50718
+ void 0,
50719
+ (context) => symbolToExpression(symbol, context, meaning)
50720
+ ),
50721
+ symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50722
+ enclosingDeclaration,
50723
+ flags,
50724
+ internalFlags,
50725
+ tracker,
50726
+ /*verbosityLevel*/
50727
+ void 0,
50728
+ (context) => typeParametersToTypeParameterDeclarations(symbol, context)
50729
+ ),
50730
+ symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50731
+ enclosingDeclaration,
50732
+ flags,
50733
+ internalFlags,
50734
+ tracker,
50735
+ /*verbosityLevel*/
50736
+ void 0,
50737
+ (context) => symbolToParameterDeclaration(symbol, context)
50738
+ ),
50739
+ typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeParameterToDeclaration(parameter, context), out),
50740
+ symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50741
+ enclosingDeclaration,
50742
+ flags,
50743
+ internalFlags,
50744
+ tracker,
50745
+ /*verbosityLevel*/
50746
+ void 0,
50747
+ (context) => symbolTableToDeclarationStatements(symbolTable, context)
50748
+ ),
50749
+ symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50750
+ enclosingDeclaration,
50751
+ flags,
50752
+ internalFlags,
50753
+ tracker,
50754
+ /*verbosityLevel*/
50755
+ void 0,
50756
+ (context) => symbolToNode(symbol, context, meaning)
50757
+ ),
50758
+ symbolToDeclarations
50579
50759
  };
50580
50760
  function getTypeFromTypeNode2(context, node, noMappedTypes) {
50581
50761
  const type = getTypeFromTypeNodeWithoutContext(node);
@@ -50617,7 +50797,75 @@ function createTypeChecker(host) {
50617
50797
  }
50618
50798
  return symbolToExpression(symbol, context, meaning);
50619
50799
  }
50620
- function withContext(enclosingDeclaration, flags, internalFlags, tracker, cb) {
50800
+ function symbolToDeclarations(symbol, meaning, flags, verbosityLevel, out) {
50801
+ const nodes = withContext(
50802
+ /*enclosingDeclaration*/
50803
+ void 0,
50804
+ flags,
50805
+ /*internalFlags*/
50806
+ void 0,
50807
+ /*tracker*/
50808
+ void 0,
50809
+ verbosityLevel,
50810
+ (context) => symbolToDeclarationsWorker(symbol, context),
50811
+ out
50812
+ );
50813
+ return mapDefined(nodes, (node) => {
50814
+ switch (node.kind) {
50815
+ case 263 /* ClassDeclaration */:
50816
+ return simplifyClassDeclaration(node, symbol);
50817
+ case 266 /* EnumDeclaration */:
50818
+ return simplifyModifiers(node, isEnumDeclaration, symbol);
50819
+ case 264 /* InterfaceDeclaration */:
50820
+ return simplifyInterfaceDeclaration(node, symbol, meaning);
50821
+ case 267 /* ModuleDeclaration */:
50822
+ return simplifyModifiers(node, isModuleDeclaration, symbol);
50823
+ default:
50824
+ return void 0;
50825
+ }
50826
+ });
50827
+ }
50828
+ function simplifyClassDeclaration(classDecl, symbol) {
50829
+ const classDeclarations = filter(symbol.declarations, isClassLike);
50830
+ const originalClassDecl = classDeclarations && classDeclarations.length > 0 ? classDeclarations[0] : classDecl;
50831
+ const modifiers = getEffectiveModifierFlags(originalClassDecl) & ~(32 /* Export */ | 128 /* Ambient */);
50832
+ const isAnonymous = isClassExpression(originalClassDecl);
50833
+ if (isAnonymous) {
50834
+ classDecl = factory.updateClassDeclaration(
50835
+ classDecl,
50836
+ classDecl.modifiers,
50837
+ /*name*/
50838
+ void 0,
50839
+ classDecl.typeParameters,
50840
+ classDecl.heritageClauses,
50841
+ classDecl.members
50842
+ );
50843
+ }
50844
+ return factory.replaceModifiers(classDecl, modifiers);
50845
+ }
50846
+ function simplifyModifiers(newDecl, isDeclKind, symbol) {
50847
+ const decls = filter(symbol.declarations, isDeclKind);
50848
+ const declWithModifiers = decls && decls.length > 0 ? decls[0] : newDecl;
50849
+ const modifiers = getEffectiveModifierFlags(declWithModifiers) & ~(32 /* Export */ | 128 /* Ambient */);
50850
+ return factory.replaceModifiers(newDecl, modifiers);
50851
+ }
50852
+ function simplifyInterfaceDeclaration(interfaceDecl, symbol, meaning) {
50853
+ if (!(meaning & 64 /* Interface */)) {
50854
+ return void 0;
50855
+ }
50856
+ return simplifyModifiers(interfaceDecl, isInterfaceDeclaration, symbol);
50857
+ }
50858
+ function symbolToDeclarationsWorker(symbol, context) {
50859
+ const type = getDeclaredTypeOfSymbol(symbol);
50860
+ context.typeStack.push(type.id);
50861
+ context.typeStack.push(-1);
50862
+ const table = createSymbolTable([symbol]);
50863
+ const statements = symbolTableToDeclarationStatements(table, context);
50864
+ context.typeStack.pop();
50865
+ context.typeStack.pop();
50866
+ return statements;
50867
+ }
50868
+ function withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, cb, out) {
50621
50869
  const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : (internalFlags || 0 /* None */) & 4 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
50622
50870
  const context = {
50623
50871
  enclosingDeclaration,
@@ -50625,6 +50873,7 @@ function createTypeChecker(host) {
50625
50873
  flags: flags || 0 /* None */,
50626
50874
  internalFlags: internalFlags || 0 /* None */,
50627
50875
  tracker: void 0,
50876
+ maxExpansionDepth: verbosityLevel ?? -1,
50628
50877
  encounteredError: false,
50629
50878
  suppressReportInferenceFallback: false,
50630
50879
  reportedDiagnostic: false,
@@ -50646,13 +50895,23 @@ function createTypeChecker(host) {
50646
50895
  typeParameterNamesByText: void 0,
50647
50896
  typeParameterNamesByTextNextNameCount: void 0,
50648
50897
  enclosingSymbolTypes: /* @__PURE__ */ new Map(),
50649
- mapper: void 0
50898
+ mapper: void 0,
50899
+ depth: 0,
50900
+ typeStack: [],
50901
+ out: {
50902
+ canIncreaseExpansionDepth: false,
50903
+ truncated: false
50904
+ }
50650
50905
  };
50651
50906
  context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
50652
50907
  const resultingNode = cb(context);
50653
50908
  if (context.truncating && context.flags & 1 /* NoTruncation */) {
50654
50909
  context.tracker.reportTruncationError();
50655
50910
  }
50911
+ if (out) {
50912
+ out.canIncreaseExpansionDepth = context.out.canIncreaseExpansionDepth;
50913
+ out.truncated = context.out.truncated;
50914
+ }
50656
50915
  return context.encounteredError ? void 0 : resultingNode;
50657
50916
  }
50658
50917
  function addSymbolTypeToContext(context, symbol, type) {
@@ -50671,19 +50930,49 @@ function createTypeChecker(host) {
50671
50930
  function saveRestoreFlags(context) {
50672
50931
  const flags = context.flags;
50673
50932
  const internalFlags = context.internalFlags;
50933
+ const depth = context.depth;
50674
50934
  return restore;
50675
50935
  function restore() {
50676
50936
  context.flags = flags;
50677
50937
  context.internalFlags = internalFlags;
50938
+ context.depth = depth;
50678
50939
  }
50679
50940
  }
50941
+ function checkTruncationLengthIfExpanding(context) {
50942
+ return context.maxExpansionDepth >= 0 && checkTruncationLength(context);
50943
+ }
50680
50944
  function checkTruncationLength(context) {
50681
50945
  if (context.truncating) return context.truncating;
50682
50946
  return context.truncating = context.approximateLength > (context.flags & 1 /* NoTruncation */ ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
50683
50947
  }
50948
+ function canPossiblyExpandType(type, context) {
50949
+ for (let i = 0; i < context.typeStack.length - 1; i++) {
50950
+ if (context.typeStack[i] === type.id) {
50951
+ return false;
50952
+ }
50953
+ }
50954
+ return context.depth < context.maxExpansionDepth || context.depth === context.maxExpansionDepth && !context.out.canIncreaseExpansionDepth;
50955
+ }
50956
+ function shouldExpandType(type, context, isAlias = false) {
50957
+ if (!isAlias && isLibType(type)) {
50958
+ return false;
50959
+ }
50960
+ for (let i = 0; i < context.typeStack.length - 1; i++) {
50961
+ if (context.typeStack[i] === type.id) {
50962
+ return false;
50963
+ }
50964
+ }
50965
+ const result = context.depth < context.maxExpansionDepth;
50966
+ if (!result) {
50967
+ context.out.canIncreaseExpansionDepth = true;
50968
+ }
50969
+ return result;
50970
+ }
50684
50971
  function typeToTypeNodeHelper(type, context) {
50685
50972
  const restoreFlags = saveRestoreFlags(context);
50973
+ if (type) context.typeStack.push(type.id);
50686
50974
  const typeNode = typeToTypeNodeWorker(type, context);
50975
+ if (type) context.typeStack.pop();
50687
50976
  restoreFlags();
50688
50977
  return typeNode;
50689
50978
  }
@@ -50694,6 +50983,7 @@ function createTypeChecker(host) {
50694
50983
  }
50695
50984
  const inTypeAlias = context.flags & 8388608 /* InTypeAlias */;
50696
50985
  context.flags &= ~8388608 /* InTypeAlias */;
50986
+ let expandingEnum = false;
50697
50987
  if (!type) {
50698
50988
  if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) {
50699
50989
  context.encounteredError = true;
@@ -50761,7 +51051,11 @@ function createTypeChecker(host) {
50761
51051
  return Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
50762
51052
  }
50763
51053
  }
50764
- return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
51054
+ if (!shouldExpandType(type, context)) {
51055
+ return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
51056
+ } else {
51057
+ expandingEnum = true;
51058
+ }
50765
51059
  }
50766
51060
  if (type.flags & 128 /* StringLiteral */) {
50767
51061
  context.approximateLength += type.value.length + 2;
@@ -50828,16 +51122,34 @@ function createTypeChecker(host) {
50828
51122
  return factory.createThisTypeNode();
50829
51123
  }
50830
51124
  if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
50831
- const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
50832
- if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
50833
- if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
50834
- return factory.createArrayTypeNode(typeArgumentNodes[0]);
51125
+ if (!shouldExpandType(
51126
+ type,
51127
+ context,
51128
+ /*isAlias*/
51129
+ true
51130
+ )) {
51131
+ const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
51132
+ if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
51133
+ if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
51134
+ return factory.createArrayTypeNode(typeArgumentNodes[0]);
51135
+ }
51136
+ return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
50835
51137
  }
50836
- return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
51138
+ context.depth += 1;
50837
51139
  }
50838
51140
  const objectFlags = getObjectFlags(type);
50839
51141
  if (objectFlags & 4 /* Reference */) {
50840
51142
  Debug.assert(!!(type.flags & 524288 /* Object */));
51143
+ if (shouldExpandType(type, context)) {
51144
+ context.depth += 1;
51145
+ return createAnonymousTypeNode(
51146
+ type,
51147
+ /*forceClassExpansion*/
51148
+ true,
51149
+ /*forceExpansion*/
51150
+ true
51151
+ );
51152
+ }
50841
51153
  return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
50842
51154
  }
50843
51155
  if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
@@ -50867,6 +51179,16 @@ function createTypeChecker(host) {
50867
51179
  void 0
50868
51180
  );
50869
51181
  }
51182
+ if (objectFlags & 3 /* ClassOrInterface */ && shouldExpandType(type, context)) {
51183
+ context.depth += 1;
51184
+ return createAnonymousTypeNode(
51185
+ type,
51186
+ /*forceClassExpansion*/
51187
+ true,
51188
+ /*forceExpansion*/
51189
+ true
51190
+ );
51191
+ }
50870
51192
  if (type.symbol) {
50871
51193
  return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
50872
51194
  }
@@ -50881,7 +51203,7 @@ function createTypeChecker(host) {
50881
51203
  type = type.origin;
50882
51204
  }
50883
51205
  if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
50884
- const types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types;
51206
+ const types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types, expandingEnum) : type.types;
50885
51207
  if (length(types) === 1) {
50886
51208
  return typeToTypeNodeHelper(types[0], context);
50887
51209
  }
@@ -51070,7 +51392,7 @@ function createTypeChecker(host) {
51070
51392
  }
51071
51393
  return result;
51072
51394
  }
51073
- function createAnonymousTypeNode(type2) {
51395
+ function createAnonymousTypeNode(type2, forceClassExpansion = false, forceExpansion = false) {
51074
51396
  var _a2, _b2;
51075
51397
  const typeId = type2.id;
51076
51398
  const symbol = type2.symbol;
@@ -51093,15 +51415,20 @@ function createTypeChecker(host) {
51093
51415
  const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
51094
51416
  if (isJSConstructor(symbol.valueDeclaration)) {
51095
51417
  return symbolToTypeNode(symbol, context, isInstanceType);
51096
- } else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
51418
+ } else if (!forceExpansion && (symbol.flags & 32 /* Class */ && !forceClassExpansion && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
51097
51419
  symbol,
51098
51420
  context.enclosingDeclaration,
51099
51421
  isInstanceType,
51100
51422
  /*shouldComputeAliasesToMakeVisible*/
51101
51423
  false
51102
- ).accessibility !== 0 /* Accessible */)) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) {
51103
- return symbolToTypeNode(symbol, context, isInstanceType);
51104
- } else if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
51424
+ ).accessibility !== 0 /* Accessible */)) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol())) {
51425
+ if (shouldExpandType(type2, context)) {
51426
+ context.depth += 1;
51427
+ } else {
51428
+ return symbolToTypeNode(symbol, context, isInstanceType);
51429
+ }
51430
+ }
51431
+ if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
51105
51432
  const typeAlias = getTypeAliasForTypeLiteral(type2);
51106
51433
  if (typeAlias) {
51107
51434
  return symbolToTypeNode(typeAlias, context, 788968 /* Type */);
@@ -51137,7 +51464,7 @@ function createTypeChecker(host) {
51137
51464
  if (id && !context.symbolDepth) {
51138
51465
  context.symbolDepth = /* @__PURE__ */ new Map();
51139
51466
  }
51140
- const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
51467
+ const links = context.maxExpansionDepth >= 0 ? void 0 : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
51141
51468
  const key = `${getTypeId(type2)}|${context.flags}|${context.internalFlags}`;
51142
51469
  if (links) {
51143
51470
  links.serializedTypes || (links.serializedTypes = /* @__PURE__ */ new Map());
@@ -51454,6 +51781,7 @@ function createTypeChecker(host) {
51454
51781
  }
51455
51782
  function createTypeNodesFromResolvedType(resolvedType) {
51456
51783
  if (checkTruncationLength(context)) {
51784
+ context.out.truncated = true;
51457
51785
  if (context.flags & 1 /* NoTruncation */) {
51458
51786
  return [addSyntheticTrailingComment(factory.createNotEmittedTypeElement(), 3 /* MultiLineCommentTrivia */, "elided")];
51459
51787
  }
@@ -51467,6 +51795,7 @@ function createTypeChecker(host) {
51467
51795
  void 0
51468
51796
  )];
51469
51797
  }
51798
+ context.typeStack.push(-1);
51470
51799
  const typeElements = [];
51471
51800
  for (const signature of resolvedType.callSignatures) {
51472
51801
  typeElements.push(signatureToSignatureDeclarationHelper(signature, 179 /* CallSignature */, context));
@@ -51480,10 +51809,14 @@ function createTypeChecker(host) {
51480
51809
  }
51481
51810
  const properties = resolvedType.properties;
51482
51811
  if (!properties) {
51812
+ context.typeStack.pop();
51483
51813
  return typeElements;
51484
51814
  }
51485
51815
  let i = 0;
51486
51816
  for (const propertySymbol of properties) {
51817
+ if (isExpanding(context) && propertySymbol.flags & 4194304 /* Prototype */) {
51818
+ continue;
51819
+ }
51487
51820
  i++;
51488
51821
  if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) {
51489
51822
  if (propertySymbol.flags & 4194304 /* Prototype */) {
@@ -51494,6 +51827,7 @@ function createTypeChecker(host) {
51494
51827
  }
51495
51828
  }
51496
51829
  if (checkTruncationLength(context) && i + 2 < properties.length - 1) {
51830
+ context.out.truncated = true;
51497
51831
  if (context.flags & 1 /* NoTruncation */) {
51498
51832
  const typeElement = typeElements.pop();
51499
51833
  typeElements.push(addSyntheticTrailingComment(typeElement, 3 /* MultiLineCommentTrivia */, `... ${properties.length - i} more elided ...`));
@@ -51513,6 +51847,7 @@ function createTypeChecker(host) {
51513
51847
  }
51514
51848
  addPropertyToElementList(propertySymbol, context, typeElements);
51515
51849
  }
51850
+ context.typeStack.pop();
51516
51851
  return typeElements.length ? typeElements : void 0;
51517
51852
  }
51518
51853
  }
@@ -51661,6 +51996,7 @@ function createTypeChecker(host) {
51661
51996
  function mapToTypeNodes(types, context, isBareList) {
51662
51997
  if (some(types)) {
51663
51998
  if (checkTruncationLength(context)) {
51999
+ context.out.truncated = true;
51664
52000
  if (!isBareList) {
51665
52001
  return [
51666
52002
  context.flags & 1 /* NoTruncation */ ? addSyntheticLeadingComment(factory.createKeywordTypeNode(133 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "elided") : factory.createTypeReferenceNode(
@@ -51688,6 +52024,7 @@ function createTypeChecker(host) {
51688
52024
  for (const type of types) {
51689
52025
  i++;
51690
52026
  if (checkTruncationLength(context) && i + 2 < types.length - 1) {
52027
+ context.out.truncated = true;
51691
52028
  result.push(
51692
52029
  context.flags & 1 /* NoTruncation */ ? addSyntheticLeadingComment(factory.createKeywordTypeNode(133 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, `... ${types.length - i} more elided ...`) : factory.createTypeReferenceNode(
51693
52030
  `... ${types.length - i} more ...`,
@@ -52085,7 +52422,7 @@ function createTypeChecker(host) {
52085
52422
  return factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
52086
52423
  }
52087
52424
  function typeToTypeNodeHelperWithPossibleReusableTypeNode(type, typeNode, context) {
52088
- return typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
52425
+ return !canPossiblyExpandType(type, context) && typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
52089
52426
  }
52090
52427
  function typeParameterToDeclaration(type, context, constraint = getConstraintOfTypeParameter(type)) {
52091
52428
  const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context);
@@ -52604,12 +52941,15 @@ function createTypeChecker(host) {
52604
52941
  }
52605
52942
  let firstChar = symbolName2.charCodeAt(0);
52606
52943
  if (isSingleOrDoubleQuote(firstChar) && some(symbol2.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
52607
- return factory.createStringLiteral(getSpecifierForModuleSymbol(symbol2, context));
52944
+ const specifier = getSpecifierForModuleSymbol(symbol2, context);
52945
+ context.approximateLength += 2 + specifier.length;
52946
+ return factory.createStringLiteral(specifier);
52608
52947
  }
52609
52948
  if (index === 0 || canUsePropertyAccess(symbolName2, languageVersion)) {
52610
52949
  const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
52611
52950
  if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
52612
52951
  identifier.symbol = symbol2;
52952
+ context.approximateLength += 1 + symbolName2.length;
52613
52953
  return index > 0 ? factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), identifier) : identifier;
52614
52954
  } else {
52615
52955
  if (firstChar === 91 /* openBracket */) {
@@ -52618,16 +52958,21 @@ function createTypeChecker(host) {
52618
52958
  }
52619
52959
  let expression;
52620
52960
  if (isSingleOrDoubleQuote(firstChar) && !(symbol2.flags & 8 /* EnumMember */)) {
52621
- expression = factory.createStringLiteral(stripQuotes(symbolName2).replace(/\\./g, (s) => s.substring(1)), firstChar === 39 /* singleQuote */);
52961
+ const literalText = stripQuotes(symbolName2).replace(/\\./g, (s) => s.substring(1));
52962
+ context.approximateLength += literalText.length + 2;
52963
+ expression = factory.createStringLiteral(literalText, firstChar === 39 /* singleQuote */);
52622
52964
  } else if ("" + +symbolName2 === symbolName2) {
52965
+ context.approximateLength += symbolName2.length;
52623
52966
  expression = factory.createNumericLiteral(+symbolName2);
52624
52967
  }
52625
52968
  if (!expression) {
52626
52969
  const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
52627
52970
  if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
52628
52971
  identifier.symbol = symbol2;
52972
+ context.approximateLength += symbolName2.length;
52629
52973
  expression = identifier;
52630
52974
  }
52975
+ context.approximateLength += 2;
52631
52976
  return factory.createElementAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), expression);
52632
52977
  }
52633
52978
  }
@@ -52656,6 +53001,10 @@ function createTypeChecker(host) {
52656
53001
  ), "'")));
52657
53002
  }
52658
53003
  function getPropertyNameNodeForSymbol(symbol, context) {
53004
+ const hashPrivateName = getClonedHashPrivateName(symbol);
53005
+ if (hashPrivateName) {
53006
+ return hashPrivateName;
53007
+ }
52659
53008
  const stringNamed = !!length(symbol.declarations) && every(symbol.declarations, isStringNamed);
52660
53009
  const singleQuote = !!length(symbol.declarations) && every(symbol.declarations, isSingleQuotedStringNamed);
52661
53010
  const isMethod = !!(symbol.flags & 8192 /* Method */);
@@ -52732,7 +53081,7 @@ function createTypeChecker(host) {
52732
53081
  let result;
52733
53082
  const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
52734
53083
  const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
52735
- if (decl) {
53084
+ if (!canPossiblyExpandType(type, context) && decl) {
52736
53085
  const restore = addSymbolTypeToContext(context, symbol, type);
52737
53086
  if (isAccessor(decl)) {
52738
53087
  result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
@@ -52771,7 +53120,7 @@ function createTypeChecker(host) {
52771
53120
  let returnTypeNode;
52772
53121
  const returnType = getReturnTypeOfSignature(signature);
52773
53122
  if (!(suppressAny && isTypeAny(returnType))) {
52774
- if (signature.declaration && !nodeIsSynthesized(signature.declaration)) {
53123
+ if (signature.declaration && !nodeIsSynthesized(signature.declaration) && !canPossiblyExpandType(returnType, context)) {
52775
53124
  const declarationSymbol = getSymbolOfDeclaration(signature.declaration);
52776
53125
  const restore = addSymbolTypeToContext(context, declarationSymbol, returnType);
52777
53126
  returnTypeNode = syntacticNodeBuilder.serializeReturnTypeForSignature(signature.declaration, declarationSymbol, context);
@@ -53182,14 +53531,28 @@ function createTypeChecker(host) {
53182
53531
  if (!suppressNewPrivateContext) {
53183
53532
  deferredPrivatesStack.push(/* @__PURE__ */ new Map());
53184
53533
  }
53185
- symbolTable2.forEach((symbol) => {
53534
+ let i = 0;
53535
+ const symbols = Array.from(symbolTable2.values());
53536
+ for (const symbol of symbols) {
53537
+ i++;
53538
+ if (checkTruncationLengthIfExpanding(context) && i + 2 < symbolTable2.size - 1) {
53539
+ context.out.truncated = true;
53540
+ results.push(createTruncationStatement(`... (${symbolTable2.size - i} more ...)`));
53541
+ serializeSymbol(
53542
+ symbols[symbols.length - 1],
53543
+ /*isPrivate*/
53544
+ false,
53545
+ !!propertyAsAlias
53546
+ );
53547
+ break;
53548
+ }
53186
53549
  serializeSymbol(
53187
53550
  symbol,
53188
53551
  /*isPrivate*/
53189
53552
  false,
53190
53553
  !!propertyAsAlias
53191
53554
  );
53192
- });
53555
+ }
53193
53556
  if (!suppressNewPrivateContext) {
53194
53557
  deferredPrivatesStack[deferredPrivatesStack.length - 1].forEach((symbol) => {
53195
53558
  serializeSymbol(
@@ -53219,7 +53582,7 @@ function createTypeChecker(host) {
53219
53582
  }
53220
53583
  }
53221
53584
  function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias, escapedSymbolName = symbol.escapedName) {
53222
- var _a2, _b, _c, _d, _e, _f;
53585
+ var _a2, _b, _c, _d, _e, _f, _g;
53223
53586
  const symbolName2 = unescapeLeadingUnderscores(escapedSymbolName);
53224
53587
  const isDefault = escapedSymbolName === "default" /* Default */;
53225
53588
  if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && isStringANonContextualKeyword(symbolName2) && !isDefault) {
@@ -53269,6 +53632,7 @@ function createTypeChecker(host) {
53269
53632
  const propertyAccessRequire = (_e = symbol.declarations) == null ? void 0 : _e.find(isPropertyAccessExpression);
53270
53633
  if (propertyAccessRequire && isBinaryExpression(propertyAccessRequire.parent) && isIdentifier(propertyAccessRequire.parent.right) && ((_f = type.symbol) == null ? void 0 : _f.valueDeclaration) && isSourceFile(type.symbol.valueDeclaration)) {
53271
53634
  const alias = localName === propertyAccessRequire.parent.right.escapedText ? void 0 : propertyAccessRequire.parent.right;
53635
+ context.approximateLength += 12 + (((_g = alias == null ? void 0 : alias.escapedText) == null ? void 0 : _g.length) ?? 0);
53272
53636
  addResult(
53273
53637
  factory.createExportDeclaration(
53274
53638
  /*modifiers*/
@@ -53308,8 +53672,10 @@ function createTypeChecker(host) {
53308
53672
  ),
53309
53673
  textRange
53310
53674
  );
53675
+ context.approximateLength += 7 + name.length;
53311
53676
  addResult(statement, name !== localName ? modifierFlags & ~32 /* Export */ : modifierFlags);
53312
53677
  if (name !== localName && !isPrivate) {
53678
+ context.approximateLength += 16 + name.length + localName.length;
53313
53679
  addResult(
53314
53680
  factory.createExportDeclaration(
53315
53681
  /*modifiers*/
@@ -53359,27 +53725,33 @@ function createTypeChecker(host) {
53359
53725
  for (const node of symbol.declarations) {
53360
53726
  const resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
53361
53727
  if (!resolvedModule) continue;
53728
+ const isTypeOnly = node.isTypeOnly;
53729
+ const specifier = getSpecifierForModuleSymbol(resolvedModule, context);
53730
+ context.approximateLength += 17 + specifier.length;
53362
53731
  addResult(factory.createExportDeclaration(
53363
53732
  /*modifiers*/
53364
53733
  void 0,
53365
- /*isTypeOnly*/
53366
- node.isTypeOnly,
53734
+ isTypeOnly,
53367
53735
  /*exportClause*/
53368
53736
  void 0,
53369
- factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))
53737
+ factory.createStringLiteral(specifier)
53370
53738
  ), 0 /* None */);
53371
53739
  }
53372
53740
  }
53373
53741
  }
53374
53742
  if (needsPostExportDefault) {
53743
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53744
+ context.approximateLength += 16 + internalSymbolName.length;
53375
53745
  addResult(factory.createExportAssignment(
53376
53746
  /*modifiers*/
53377
53747
  void 0,
53378
53748
  /*isExportEquals*/
53379
53749
  false,
53380
- factory.createIdentifier(getInternalSymbolName(symbol, symbolName2))
53750
+ factory.createIdentifier(internalSymbolName)
53381
53751
  ), 0 /* None */);
53382
53752
  } else if (needsExportDeclaration) {
53753
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53754
+ context.approximateLength += 22 + symbolName2.length + internalSymbolName.length;
53383
53755
  addResult(
53384
53756
  factory.createExportDeclaration(
53385
53757
  /*modifiers*/
@@ -53389,7 +53761,7 @@ function createTypeChecker(host) {
53389
53761
  factory.createNamedExports([factory.createExportSpecifier(
53390
53762
  /*isTypeOnly*/
53391
53763
  false,
53392
- getInternalSymbolName(symbol, symbolName2),
53764
+ internalSymbolName,
53393
53765
  symbolName2
53394
53766
  )])
53395
53767
  ),
@@ -53409,6 +53781,7 @@ function createTypeChecker(host) {
53409
53781
  }
53410
53782
  function addResult(node, additionalModifierFlags) {
53411
53783
  if (canHaveModifiers(node)) {
53784
+ const oldModifierFlags = getEffectiveModifierFlags(node);
53412
53785
  let newModifierFlags = 0 /* None */;
53413
53786
  const enclosingDeclaration2 = context.enclosingDeclaration && (isJSDocTypeAlias(context.enclosingDeclaration) ? getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
53414
53787
  if (additionalModifierFlags & 32 /* Export */ && enclosingDeclaration2 && (isExportingScope(enclosingDeclaration2) || isModuleDeclaration(enclosingDeclaration2)) && canHaveExportModifier(node)) {
@@ -53421,8 +53794,9 @@ function createTypeChecker(host) {
53421
53794
  newModifierFlags |= 2048 /* Default */;
53422
53795
  }
53423
53796
  if (newModifierFlags) {
53424
- node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node));
53797
+ node = factory.replaceModifiers(node, newModifierFlags | oldModifierFlags);
53425
53798
  }
53799
+ context.approximateLength += modifiersLength(newModifierFlags | oldModifierFlags);
53426
53800
  }
53427
53801
  results.push(node);
53428
53802
  }
@@ -53438,12 +53812,14 @@ function createTypeChecker(host) {
53438
53812
  const oldEnclosingDecl = context.enclosingDeclaration;
53439
53813
  context.enclosingDeclaration = jsdocAliasDecl;
53440
53814
  const typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && syntacticNodeBuilder.tryReuseExistingTypeNode(context, jsdocAliasDecl.typeExpression.type) || typeToTypeNodeHelper(aliasType, context);
53815
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53816
+ context.approximateLength += 8 + ((commentText == null ? void 0 : commentText.length) ?? 0) + internalSymbolName.length;
53441
53817
  addResult(
53442
53818
  setSyntheticLeadingComments(
53443
53819
  factory.createTypeAliasDeclaration(
53444
53820
  /*modifiers*/
53445
53821
  void 0,
53446
- getInternalSymbolName(symbol, symbolName2),
53822
+ internalSymbolName,
53447
53823
  typeParamDecls,
53448
53824
  typeNode
53449
53825
  ),
@@ -53455,12 +53831,19 @@ function createTypeChecker(host) {
53455
53831
  context.enclosingDeclaration = oldEnclosingDecl;
53456
53832
  }
53457
53833
  function serializeInterface(symbol, symbolName2, modifierFlags) {
53834
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53835
+ context.approximateLength += 14 + internalSymbolName.length;
53458
53836
  const interfaceType = getDeclaredTypeOfClassOrInterface(symbol);
53459
53837
  const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
53460
53838
  const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
53461
53839
  const baseTypes = getBaseTypes(interfaceType);
53462
53840
  const baseType = length(baseTypes) ? getIntersectionType(baseTypes) : void 0;
53463
- const members = flatMap(getPropertiesOfType(interfaceType), (p) => serializePropertySymbolForInterface(p, baseType));
53841
+ const members = serializePropertySymbolsForClassOrInterface(
53842
+ getPropertiesOfType(interfaceType),
53843
+ /*isClass*/
53844
+ false,
53845
+ baseType
53846
+ );
53464
53847
  const callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 179 /* CallSignature */);
53465
53848
  const constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 180 /* ConstructSignature */);
53466
53849
  const indexSignatures = serializeIndexSignatures(interfaceType, baseType);
@@ -53469,7 +53852,7 @@ function createTypeChecker(host) {
53469
53852
  factory.createInterfaceDeclaration(
53470
53853
  /*modifiers*/
53471
53854
  void 0,
53472
- getInternalSymbolName(symbol, symbolName2),
53855
+ internalSymbolName,
53473
53856
  typeParamDecls,
53474
53857
  heritageClauses,
53475
53858
  [...indexSignatures, ...constructSignatures, ...callSignatures, ...members]
@@ -53477,6 +53860,57 @@ function createTypeChecker(host) {
53477
53860
  modifierFlags
53478
53861
  );
53479
53862
  }
53863
+ function serializePropertySymbolsForClassOrInterface(props, isClass, baseType, isStatic2) {
53864
+ const elements = [];
53865
+ let i = 0;
53866
+ for (const prop of props) {
53867
+ i++;
53868
+ if (checkTruncationLengthIfExpanding(context) && i + 2 < props.length - 1) {
53869
+ context.out.truncated = true;
53870
+ const placeholder = createTruncationProperty(`... ${props.length - i} more ... `, isClass);
53871
+ elements.push(placeholder);
53872
+ const result2 = isClass ? serializePropertySymbolForClass(props[props.length - 1], isStatic2, baseType) : serializePropertySymbolForInterface(props[props.length - 1], baseType);
53873
+ if (isArray(result2)) {
53874
+ elements.push(...result2);
53875
+ } else {
53876
+ elements.push(result2);
53877
+ }
53878
+ break;
53879
+ }
53880
+ context.approximateLength += 1;
53881
+ const result = isClass ? serializePropertySymbolForClass(prop, isStatic2, baseType) : serializePropertySymbolForInterface(prop, baseType);
53882
+ if (isArray(result)) {
53883
+ elements.push(...result);
53884
+ } else {
53885
+ elements.push(result);
53886
+ }
53887
+ }
53888
+ return elements;
53889
+ }
53890
+ function createTruncationProperty(dotDotDotText, isClass) {
53891
+ if (context.flags & 1 /* NoTruncation */) {
53892
+ return addSyntheticLeadingComment(factory.createNotEmittedTypeElement(), 3 /* MultiLineCommentTrivia */, dotDotDotText);
53893
+ }
53894
+ return isClass ? factory.createPropertyDeclaration(
53895
+ /*modifiers*/
53896
+ void 0,
53897
+ dotDotDotText,
53898
+ /*questionOrExclamationToken*/
53899
+ void 0,
53900
+ /*type*/
53901
+ void 0,
53902
+ /*initializer*/
53903
+ void 0
53904
+ ) : factory.createPropertySignature(
53905
+ /*modifiers*/
53906
+ void 0,
53907
+ dotDotDotText,
53908
+ /*questionToken*/
53909
+ void 0,
53910
+ /*type*/
53911
+ void 0
53912
+ );
53913
+ }
53480
53914
  function getNamespaceMembersForSerialization(symbol) {
53481
53915
  let exports2 = arrayFrom(getExportsOfSymbol(symbol).values());
53482
53916
  const merged = getMergedSymbol(symbol);
@@ -53496,11 +53930,27 @@ function createTypeChecker(host) {
53496
53930
  }
53497
53931
  function serializeModule(symbol, symbolName2, modifierFlags) {
53498
53932
  const members = getNamespaceMembersForSerialization(symbol);
53499
- const locationMap = arrayToMultiMap(members, (m) => m.parent && m.parent === symbol ? "real" : "merged");
53933
+ const expanding = isExpanding(context);
53934
+ const locationMap = arrayToMultiMap(members, (m) => m.parent && m.parent === symbol || expanding ? "real" : "merged");
53500
53935
  const realMembers = locationMap.get("real") || emptyArray;
53501
53936
  const mergedMembers = locationMap.get("merged") || emptyArray;
53502
- if (length(realMembers)) {
53503
- const localName = getInternalSymbolName(symbol, symbolName2);
53937
+ if (length(realMembers) || expanding) {
53938
+ let localName;
53939
+ if (expanding) {
53940
+ const oldFlags = context.flags;
53941
+ context.flags |= 512 /* WriteTypeParametersInQualifiedName */ | 2 /* UseOnlyExternalAliasing */;
53942
+ localName = symbolToNode(
53943
+ symbol,
53944
+ context,
53945
+ /*meaning*/
53946
+ -1 /* All */
53947
+ );
53948
+ context.flags = oldFlags;
53949
+ } else {
53950
+ const localText = getInternalSymbolName(symbol, symbolName2);
53951
+ localName = factory.createIdentifier(localText);
53952
+ context.approximateLength += localText.length;
53953
+ }
53504
53954
  serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */)));
53505
53955
  }
53506
53956
  if (length(mergedMembers)) {
@@ -53548,17 +53998,51 @@ function createTypeChecker(host) {
53548
53998
  }
53549
53999
  }
53550
54000
  function serializeEnum(symbol, symbolName2, modifierFlags) {
54001
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
54002
+ context.approximateLength += 9 + internalSymbolName.length;
54003
+ const members = [];
54004
+ const memberProps = filter(getPropertiesOfType(getTypeOfSymbol(symbol)), (p) => !!(p.flags & 8 /* EnumMember */));
54005
+ let i = 0;
54006
+ for (const p of memberProps) {
54007
+ i++;
54008
+ if (checkTruncationLengthIfExpanding(context) && i + 2 < memberProps.length - 1) {
54009
+ context.out.truncated = true;
54010
+ members.push(factory.createEnumMember(` ... ${memberProps.length - i} more ... `));
54011
+ const last2 = memberProps[memberProps.length - 1];
54012
+ const initializedValue = last2.declarations && last2.declarations[0] && isEnumMember(last2.declarations[0]) ? getConstantValue2(last2.declarations[0]) : void 0;
54013
+ const initializer2 = initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue);
54014
+ const memberName2 = unescapeLeadingUnderscores(last2.escapedName);
54015
+ const member2 = factory.createEnumMember(
54016
+ memberName2,
54017
+ initializer2
54018
+ );
54019
+ members.push(member2);
54020
+ break;
54021
+ }
54022
+ const memberDecl = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? p.declarations[0] : void 0;
54023
+ let initializer;
54024
+ let initializerLength;
54025
+ if (isExpanding(context) && memberDecl && memberDecl.initializer) {
54026
+ initializer = getSynthesizedDeepClone(memberDecl.initializer);
54027
+ initializerLength = memberDecl.initializer.end - memberDecl.initializer.pos;
54028
+ } else {
54029
+ const initializedValue = memberDecl && getConstantValue2(memberDecl);
54030
+ initializer = initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue);
54031
+ initializerLength = (initializer == null ? void 0 : initializer.text.length) ?? 0;
54032
+ }
54033
+ const memberName = unescapeLeadingUnderscores(p.escapedName);
54034
+ context.approximateLength += 4 + memberName.length + initializerLength;
54035
+ const member = factory.createEnumMember(
54036
+ memberName,
54037
+ initializer
54038
+ );
54039
+ members.push(member);
54040
+ }
53551
54041
  addResult(
53552
54042
  factory.createEnumDeclaration(
53553
54043
  factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 4096 /* Const */ : 0),
53554
- getInternalSymbolName(symbol, symbolName2),
53555
- map(filter(getPropertiesOfType(getTypeOfSymbol(symbol)), (p) => !!(p.flags & 8 /* EnumMember */)), (p) => {
53556
- const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? getConstantValue2(p.declarations[0]) : void 0;
53557
- return factory.createEnumMember(
53558
- unescapeLeadingUnderscores(p.escapedName),
53559
- initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue)
53560
- );
53561
- })
54044
+ internalSymbolName,
54045
+ members
53562
54046
  ),
53563
54047
  modifierFlags
53564
54048
  );
@@ -53566,20 +54050,28 @@ function createTypeChecker(host) {
53566
54050
  function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
53567
54051
  const signatures = getSignaturesOfType(type, 0 /* Call */);
53568
54052
  for (const sig of signatures) {
54053
+ context.approximateLength += 1;
53569
54054
  const decl = signatureToSignatureDeclarationHelper(sig, 262 /* FunctionDeclaration */, context, { name: factory.createIdentifier(localName) });
53570
54055
  addResult(setTextRange2(context, decl, getSignatureTextRangeLocation(sig)), modifierFlags);
53571
54056
  }
53572
54057
  if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) {
53573
54058
  const props = filter(getPropertiesOfType(type), isNamespaceMember);
54059
+ context.approximateLength += localName.length;
53574
54060
  serializeAsNamespaceDeclaration(
53575
54061
  props,
53576
- localName,
54062
+ factory.createIdentifier(localName),
53577
54063
  modifierFlags,
53578
54064
  /*suppressNewPrivateContext*/
53579
54065
  true
53580
54066
  );
53581
54067
  }
53582
54068
  }
54069
+ function createTruncationStatement(dotDotDotText) {
54070
+ if (context.flags & 1 /* NoTruncation */) {
54071
+ return addSyntheticLeadingComment(factory.createEmptyStatement(), 3 /* MultiLineCommentTrivia */, dotDotDotText);
54072
+ }
54073
+ return factory.createExpressionStatement(factory.createIdentifier(dotDotDotText));
54074
+ }
53583
54075
  function getSignatureTextRangeLocation(signature) {
53584
54076
  if (signature.declaration && signature.declaration.parent) {
53585
54077
  if (isBinaryExpression(signature.declaration.parent) && getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) {
@@ -53592,15 +54084,18 @@ function createTypeChecker(host) {
53592
54084
  return signature.declaration;
53593
54085
  }
53594
54086
  function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) {
54087
+ const nodeFlags = isIdentifier(localName) ? 32 /* Namespace */ : 0 /* None */;
54088
+ const expanding = isExpanding(context);
53595
54089
  if (length(props)) {
53596
- const localVsRemoteMap = arrayToMultiMap(props, (p) => !length(p.declarations) || some(p.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)) ? "local" : "remote");
54090
+ context.approximateLength += 14;
54091
+ const localVsRemoteMap = arrayToMultiMap(props, (p) => !length(p.declarations) || some(p.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)) || expanding ? "local" : "remote");
53597
54092
  const localProps = localVsRemoteMap.get("local") || emptyArray;
53598
54093
  let fakespace = parseNodeFactory.createModuleDeclaration(
53599
54094
  /*modifiers*/
53600
54095
  void 0,
53601
- factory.createIdentifier(localName),
54096
+ localName,
53602
54097
  factory.createModuleBlock([]),
53603
- 32 /* Namespace */
54098
+ nodeFlags
53604
54099
  );
53605
54100
  setParent(fakespace, enclosingDeclaration);
53606
54101
  fakespace.locals = createSymbolTable(props);
@@ -53642,6 +54137,18 @@ function createTypeChecker(host) {
53642
54137
  factory.createModuleBlock(exportModifierStripped)
53643
54138
  );
53644
54139
  addResult(fakespace, modifierFlags);
54140
+ } else if (expanding) {
54141
+ context.approximateLength += 14;
54142
+ addResult(
54143
+ factory.createModuleDeclaration(
54144
+ /*modifiers*/
54145
+ void 0,
54146
+ localName,
54147
+ factory.createModuleBlock([]),
54148
+ nodeFlags
54149
+ ),
54150
+ modifierFlags
54151
+ );
53645
54152
  }
53646
54153
  }
53647
54154
  function isNamespaceMember(p) {
@@ -53684,11 +54191,13 @@ function createTypeChecker(host) {
53684
54191
  }
53685
54192
  function serializeAsClass(symbol, localName, modifierFlags) {
53686
54193
  var _a2, _b;
54194
+ context.approximateLength += 9 + localName.length;
53687
54195
  const originalDecl = (_a2 = symbol.declarations) == null ? void 0 : _a2.find(isClassLike);
53688
54196
  const oldEnclosing = context.enclosingDeclaration;
53689
54197
  context.enclosingDeclaration = originalDecl || oldEnclosing;
53690
54198
  const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
53691
54199
  const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
54200
+ forEach(localParams, (p) => context.approximateLength += symbolName(p.symbol).length);
53692
54201
  const classType = getTypeWithThisArgument(getDeclaredTypeOfClassOrInterface(symbol));
53693
54202
  const baseTypes = getBaseTypes(classType);
53694
54203
  const originalImplements = originalDecl && getEffectiveImplementsTypeNodes(originalDecl);
@@ -53696,20 +54205,22 @@ function createTypeChecker(host) {
53696
54205
  const staticType = getTypeOfSymbol(symbol);
53697
54206
  const isClass = !!((_b = staticType.symbol) == null ? void 0 : _b.valueDeclaration) && isClassLike(staticType.symbol.valueDeclaration);
53698
54207
  const staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType;
54208
+ context.approximateLength += (length(baseTypes) ? 8 : 0) + (length(implementsExpressions) ? 11 : 0);
53699
54209
  const heritageClauses = [
53700
54210
  ...!length(baseTypes) ? [] : [factory.createHeritageClause(96 /* ExtendsKeyword */, map(baseTypes, (b) => serializeBaseType(b, staticBaseType, localName)))],
53701
54211
  ...!length(implementsExpressions) ? [] : [factory.createHeritageClause(119 /* ImplementsKeyword */, implementsExpressions)]
53702
54212
  ];
53703
54213
  const symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType));
53704
- const publicSymbolProps = filter(symbolProps, (s) => {
53705
- const valueDecl = s.valueDeclaration;
53706
- return !!valueDecl && !(isNamedDeclaration(valueDecl) && isPrivateIdentifier(valueDecl.name));
53707
- });
53708
- const hasPrivateIdentifier = some(symbolProps, (s) => {
53709
- const valueDecl = s.valueDeclaration;
53710
- return !!valueDecl && isNamedDeclaration(valueDecl) && isPrivateIdentifier(valueDecl.name);
53711
- });
53712
- const privateProperties = hasPrivateIdentifier ? [factory.createPropertyDeclaration(
54214
+ const publicSymbolProps = filter(symbolProps, (s) => !isHashPrivate(s));
54215
+ const hasPrivateIdentifier = some(symbolProps, isHashPrivate);
54216
+ const privateProperties = hasPrivateIdentifier ? isExpanding(context) ? serializePropertySymbolsForClassOrInterface(
54217
+ filter(symbolProps, isHashPrivate),
54218
+ /*isClass*/
54219
+ true,
54220
+ baseTypes[0],
54221
+ /*isStatic*/
54222
+ false
54223
+ ) : [factory.createPropertyDeclaration(
53713
54224
  /*modifiers*/
53714
54225
  void 0,
53715
54226
  factory.createPrivateIdentifier("#private"),
@@ -53720,22 +54231,27 @@ function createTypeChecker(host) {
53720
54231
  /*initializer*/
53721
54232
  void 0
53722
54233
  )] : emptyArray;
53723
- const publicProperties = flatMap(publicSymbolProps, (p) => serializePropertySymbolForClass(
53724
- p,
54234
+ if (hasPrivateIdentifier && !isExpanding(context)) {
54235
+ context.approximateLength += 9;
54236
+ }
54237
+ const publicProperties = serializePropertySymbolsForClassOrInterface(
54238
+ publicSymbolProps,
54239
+ /*isClass*/
54240
+ true,
54241
+ baseTypes[0],
53725
54242
  /*isStatic*/
53726
- false,
53727
- baseTypes[0]
53728
- ));
53729
- const staticMembers = flatMap(
54243
+ false
54244
+ );
54245
+ const staticMembers = serializePropertySymbolsForClassOrInterface(
53730
54246
  filter(getPropertiesOfType(staticType), (p) => !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p)),
53731
- (p) => serializePropertySymbolForClass(
53732
- p,
53733
- /*isStatic*/
53734
- true,
53735
- staticBaseType
53736
- )
54247
+ /*isClass*/
54248
+ true,
54249
+ staticBaseType,
54250
+ /*isStatic*/
54251
+ true
53737
54252
  );
53738
54253
  const isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && !some(getSignaturesOfType(staticType, 1 /* Construct */));
54254
+ if (isNonConstructableClassLikeInJsFile) context.approximateLength += 21;
53739
54255
  const constructors = isNonConstructableClassLikeInJsFile ? [factory.createConstructorDeclaration(
53740
54256
  factory.createModifiersFromModifierFlags(2 /* Private */),
53741
54257
  [],
@@ -53803,6 +54319,8 @@ function createTypeChecker(host) {
53803
54319
  if (((_b = (_a2 = node.parent) == null ? void 0 : _a2.parent) == null ? void 0 : _b.kind) === 260 /* VariableDeclaration */) {
53804
54320
  const specifier2 = getSpecifierForModuleSymbol(target.parent || target, context);
53805
54321
  const { propertyName } = node;
54322
+ const propertyNameText = propertyName && isIdentifier(propertyName) ? idText(propertyName) : void 0;
54323
+ context.approximateLength += 24 + localName.length + specifier2.length + ((propertyNameText == null ? void 0 : propertyNameText.length) ?? 0);
53806
54324
  addResult(
53807
54325
  factory.createImportDeclaration(
53808
54326
  /*modifiers*/
@@ -53815,7 +54333,7 @@ function createTypeChecker(host) {
53815
54333
  factory.createNamedImports([factory.createImportSpecifier(
53816
54334
  /*isTypeOnly*/
53817
54335
  false,
53818
- propertyName && isIdentifier(propertyName) ? factory.createIdentifier(idText(propertyName)) : void 0,
54336
+ propertyNameText ? factory.createIdentifier(propertyNameText) : void 0,
53819
54337
  factory.createIdentifier(localName)
53820
54338
  )])
53821
54339
  ),
@@ -53842,6 +54360,7 @@ function createTypeChecker(host) {
53842
54360
  const initializer = node.initializer;
53843
54361
  const uniqueName = factory.createUniqueName(localName);
53844
54362
  const specifier2 = getSpecifierForModuleSymbol(target.parent || target, context);
54363
+ context.approximateLength += 22 + specifier2.length + idText(uniqueName).length;
53845
54364
  addResult(
53846
54365
  factory.createImportEqualsDeclaration(
53847
54366
  /*modifiers*/
@@ -53853,6 +54372,7 @@ function createTypeChecker(host) {
53853
54372
  ),
53854
54373
  0 /* None */
53855
54374
  );
54375
+ context.approximateLength += 12 + localName.length + idText(uniqueName).length + idText(initializer.name).length;
53856
54376
  addResult(
53857
54377
  factory.createImportEqualsDeclaration(
53858
54378
  /*modifiers*/
@@ -53873,6 +54393,7 @@ function createTypeChecker(host) {
53873
54393
  break;
53874
54394
  }
53875
54395
  const isLocalImport = !(target.flags & 512 /* ValueModule */) && !isVariableDeclaration(node);
54396
+ context.approximateLength += 11 + localName.length + unescapeLeadingUnderscores(target.escapedName).length;
53876
54397
  addResult(
53877
54398
  factory.createImportEqualsDeclaration(
53878
54399
  /*modifiers*/
@@ -53899,6 +54420,7 @@ function createTypeChecker(host) {
53899
54420
  const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
53900
54421
  const attributes = isImportDeclaration(node.parent) ? node.parent.attributes : void 0;
53901
54422
  const isTypeOnly = isJSDocImportTag(node.parent);
54423
+ context.approximateLength += 14 + localName.length + 3 + (isTypeOnly ? 4 : 0);
53902
54424
  addResult(
53903
54425
  factory.createImportDeclaration(
53904
54426
  /*modifiers*/
@@ -53920,6 +54442,7 @@ function createTypeChecker(host) {
53920
54442
  const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
53921
54443
  const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
53922
54444
  const isTypeOnly = isJSDocImportTag(node.parent.parent);
54445
+ context.approximateLength += 19 + localName.length + 3 + (isTypeOnly ? 4 : 0);
53923
54446
  addResult(
53924
54447
  factory.createImportDeclaration(
53925
54448
  /*modifiers*/
@@ -53938,6 +54461,7 @@ function createTypeChecker(host) {
53938
54461
  break;
53939
54462
  }
53940
54463
  case 280 /* NamespaceExport */:
54464
+ context.approximateLength += 19 + localName.length + 3;
53941
54465
  addResult(
53942
54466
  factory.createExportDeclaration(
53943
54467
  /*modifiers*/
@@ -53954,6 +54478,7 @@ function createTypeChecker(host) {
53954
54478
  const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
53955
54479
  const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
53956
54480
  const isTypeOnly = isJSDocImportTag(node.parent.parent.parent);
54481
+ context.approximateLength += 19 + localName.length + 3 + (isTypeOnly ? 4 : 0);
53957
54482
  addResult(
53958
54483
  factory.createImportDeclaration(
53959
54484
  /*modifiers*/
@@ -54009,6 +54534,7 @@ function createTypeChecker(host) {
54009
54534
  }
54010
54535
  }
54011
54536
  function serializeExportSpecifier(localName, targetName, specifier) {
54537
+ context.approximateLength += 16 + localName.length + (localName !== targetName ? targetName.length : 0);
54012
54538
  addResult(
54013
54539
  factory.createExportDeclaration(
54014
54540
  /*modifiers*/
@@ -54059,6 +54585,7 @@ function createTypeChecker(host) {
54059
54585
  const prevDisableTrackSymbol = context.tracker.disableTrackSymbol;
54060
54586
  context.tracker.disableTrackSymbol = true;
54061
54587
  if (isExportAssignmentCompatibleSymbolName) {
54588
+ context.approximateLength += 10;
54062
54589
  results.push(factory.createExportAssignment(
54063
54590
  /*modifiers*/
54064
54591
  void 0,
@@ -54072,6 +54599,7 @@ function createTypeChecker(host) {
54072
54599
  serializeExportSpecifier(name, getInternalSymbolName(target, symbolName(target)));
54073
54600
  } else {
54074
54601
  const varName = getUnusedName(name, symbol);
54602
+ context.approximateLength += varName.length + 10;
54075
54603
  addResult(
54076
54604
  factory.createImportEqualsDeclaration(
54077
54605
  /*modifiers*/
@@ -54101,6 +54629,7 @@ function createTypeChecker(host) {
54101
54629
  serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 32 /* Export */);
54102
54630
  } else {
54103
54631
  const flags = ((_a2 = context.enclosingDeclaration) == null ? void 0 : _a2.kind) === 267 /* ModuleDeclaration */ && (!(symbol.flags & 98304 /* Accessor */) || symbol.flags & 65536 /* SetAccessor */) ? 1 /* Let */ : 2 /* Const */;
54632
+ context.approximateLength += varName.length + 5;
54104
54633
  const statement = factory.createVariableStatement(
54105
54634
  /*modifiers*/
54106
54635
  void 0,
@@ -54125,6 +54654,7 @@ function createTypeChecker(host) {
54125
54654
  );
54126
54655
  }
54127
54656
  if (isExportAssignmentCompatibleSymbolName) {
54657
+ context.approximateLength += varName.length + 10;
54128
54658
  results.push(factory.createExportAssignment(
54129
54659
  /*modifiers*/
54130
54660
  void 0,
@@ -54159,7 +54689,7 @@ function createTypeChecker(host) {
54159
54689
  return function serializePropertySymbol(p, isStatic2, baseType) {
54160
54690
  var _a2, _b, _c, _d, _e, _f;
54161
54691
  const modifierFlags = getDeclarationModifierFlagsFromSymbol(p);
54162
- const isPrivate = !!(modifierFlags & 2 /* Private */);
54692
+ const omitType = !!(modifierFlags & 2 /* Private */) && !isExpanding(context);
54163
54693
  if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) {
54164
54694
  return [];
54165
54695
  }
@@ -54188,6 +54718,7 @@ function createTypeChecker(host) {
54188
54718
  Debug.assert(!!setter);
54189
54719
  const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : void 0;
54190
54720
  const setterDeclaration = (_b = p.declarations) == null ? void 0 : _b.find(isSetAccessor);
54721
+ context.approximateLength += modifiersLength(flag) + 7 + (paramSymbol ? symbolName(paramSymbol).length : 5) + (omitType ? 0 : 2);
54191
54722
  result.push(setTextRange2(
54192
54723
  context,
54193
54724
  factory.createSetAccessorDeclaration(
@@ -54201,7 +54732,7 @@ function createTypeChecker(host) {
54201
54732
  paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
54202
54733
  /*questionToken*/
54203
54734
  void 0,
54204
- isPrivate ? void 0 : serializeTypeForDeclaration(context, setterDeclaration, getWriteTypeOfSymbol(p), p)
54735
+ omitType ? void 0 : serializeTypeForDeclaration(context, setterDeclaration, getWriteTypeOfSymbol(p), p)
54205
54736
  )],
54206
54737
  /*body*/
54207
54738
  void 0
@@ -54210,15 +54741,15 @@ function createTypeChecker(host) {
54210
54741
  ));
54211
54742
  }
54212
54743
  if (p.flags & 32768 /* GetAccessor */) {
54213
- const isPrivate2 = modifierFlags & 2 /* Private */;
54214
54744
  const getterDeclaration = (_c = p.declarations) == null ? void 0 : _c.find(isGetAccessor);
54745
+ context.approximateLength += modifiersLength(flag) + 8 + (omitType ? 0 : 2);
54215
54746
  result.push(setTextRange2(
54216
54747
  context,
54217
54748
  factory.createGetAccessorDeclaration(
54218
54749
  factory.createModifiersFromModifierFlags(flag),
54219
54750
  name,
54220
54751
  [],
54221
- isPrivate2 ? void 0 : serializeTypeForDeclaration(context, getterDeclaration, getTypeOfSymbol(p), p),
54752
+ omitType ? void 0 : serializeTypeForDeclaration(context, getterDeclaration, getTypeOfSymbol(p), p),
54222
54753
  /*body*/
54223
54754
  void 0
54224
54755
  ),
@@ -54227,13 +54758,15 @@ function createTypeChecker(host) {
54227
54758
  }
54228
54759
  return result;
54229
54760
  } else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) {
54761
+ const modifierFlags2 = (isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag;
54762
+ context.approximateLength += 2 + (omitType ? 0 : 2) + modifiersLength(modifierFlags2);
54230
54763
  return setTextRange2(
54231
54764
  context,
54232
54765
  createProperty2(
54233
- factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
54766
+ factory.createModifiersFromModifierFlags(modifierFlags2),
54234
54767
  name,
54235
54768
  p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
54236
- isPrivate ? void 0 : serializeTypeForDeclaration(context, (_d = p.declarations) == null ? void 0 : _d.find(isSetAccessorDeclaration), getWriteTypeOfSymbol(p), p),
54769
+ omitType ? void 0 : serializeTypeForDeclaration(context, (_d = p.declarations) == null ? void 0 : _d.find(isSetAccessorDeclaration), getWriteTypeOfSymbol(p), p),
54237
54770
  // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357
54238
54771
  // interface members can't have initializers, however class members _can_
54239
54772
  /*initializer*/
@@ -54245,11 +54778,13 @@ function createTypeChecker(host) {
54245
54778
  if (p.flags & (8192 /* Method */ | 16 /* Function */)) {
54246
54779
  const type = getTypeOfSymbol(p);
54247
54780
  const signatures = getSignaturesOfType(type, 0 /* Call */);
54248
- if (flag & 2 /* Private */) {
54781
+ if (omitType) {
54782
+ const modifierFlags2 = (isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag;
54783
+ context.approximateLength += 1 + modifiersLength(modifierFlags2);
54249
54784
  return setTextRange2(
54250
54785
  context,
54251
54786
  createProperty2(
54252
- factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
54787
+ factory.createModifiersFromModifierFlags(modifierFlags2),
54253
54788
  name,
54254
54789
  p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
54255
54790
  /*type*/
@@ -54262,6 +54797,7 @@ function createTypeChecker(host) {
54262
54797
  }
54263
54798
  const results2 = [];
54264
54799
  for (const sig of signatures) {
54800
+ context.approximateLength += 1;
54265
54801
  const decl = signatureToSignatureDeclarationHelper(
54266
54802
  sig,
54267
54803
  methodKind,
@@ -54280,6 +54816,25 @@ function createTypeChecker(host) {
54280
54816
  return Debug.fail(`Unhandled class member kind! ${p.__debugFlags || p.flags}`);
54281
54817
  };
54282
54818
  }
54819
+ function modifiersLength(flags) {
54820
+ let result = 0;
54821
+ if (flags & 32 /* Export */) result += 7;
54822
+ if (flags & 128 /* Ambient */) result += 8;
54823
+ if (flags & 2048 /* Default */) result += 8;
54824
+ if (flags & 4096 /* Const */) result += 6;
54825
+ if (flags & 1 /* Public */) result += 7;
54826
+ if (flags & 2 /* Private */) result += 8;
54827
+ if (flags & 4 /* Protected */) result += 10;
54828
+ if (flags & 64 /* Abstract */) result += 9;
54829
+ if (flags & 256 /* Static */) result += 7;
54830
+ if (flags & 16 /* Override */) result += 9;
54831
+ if (flags & 8 /* Readonly */) result += 9;
54832
+ if (flags & 512 /* Accessor */) result += 9;
54833
+ if (flags & 1024 /* Async */) result += 6;
54834
+ if (flags & 8192 /* In */) result += 3;
54835
+ if (flags & 16384 /* Out */) result += 4;
54836
+ return result;
54837
+ }
54283
54838
  function serializePropertySymbolForInterface(p, baseType) {
54284
54839
  return serializePropertySymbolForInterfaceWorker(
54285
54840
  p,
@@ -54344,6 +54899,7 @@ function createTypeChecker(host) {
54344
54899
  }
54345
54900
  const results2 = [];
54346
54901
  for (const sig of signatures) {
54902
+ context.approximateLength += 1;
54347
54903
  const decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
54348
54904
  results2.push(setTextRange2(context, decl, sig.declaration));
54349
54905
  }
@@ -54469,6 +55025,23 @@ function createTypeChecker(host) {
54469
55025
  return localName;
54470
55026
  }
54471
55027
  }
55028
+ function isExpanding(context) {
55029
+ return context.maxExpansionDepth !== -1;
55030
+ }
55031
+ function isHashPrivate(s) {
55032
+ return !!s.valueDeclaration && isNamedDeclaration(s.valueDeclaration) && isPrivateIdentifier(s.valueDeclaration.name);
55033
+ }
55034
+ function getClonedHashPrivateName(s) {
55035
+ if (s.valueDeclaration && isNamedDeclaration(s.valueDeclaration) && isPrivateIdentifier(s.valueDeclaration.name)) {
55036
+ return factory.cloneNode(s.valueDeclaration.name);
55037
+ }
55038
+ return void 0;
55039
+ }
55040
+ }
55041
+ function isLibType(type) {
55042
+ var _a;
55043
+ const symbol = (getObjectFlags(type) & 4 /* Reference */) !== 0 ? type.target.symbol : type.symbol;
55044
+ return isTupleType(type) || !!((_a = symbol == null ? void 0 : symbol.declarations) == null ? void 0 : _a.some((decl) => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl))));
54472
55045
  }
54473
55046
  function typePredicateToString(typePredicate, enclosingDeclaration, flags = 16384 /* UseAliasDefinedOutsideCurrentScope */, writer) {
54474
55047
  return writer ? typePredicateToStringWorker(writer).getText() : usingSingleLineStringWriter(typePredicateToStringWorker);
@@ -54487,14 +55060,14 @@ function createTypeChecker(host) {
54487
55060
  return writer2;
54488
55061
  }
54489
55062
  }
54490
- function formatUnionTypes(types) {
55063
+ function formatUnionTypes(types, expandingEnum) {
54491
55064
  const result = [];
54492
55065
  let flags = 0;
54493
55066
  for (let i = 0; i < types.length; i++) {
54494
55067
  const t = types[i];
54495
55068
  flags |= t.flags;
54496
55069
  if (!(t.flags & 98304 /* Nullable */)) {
54497
- if (t.flags & (512 /* BooleanLiteral */ | 1056 /* EnumLike */)) {
55070
+ if (t.flags & 512 /* BooleanLiteral */ || !expandingEnum && t.flags | 1056 /* EnumLike */) {
54498
55071
  const baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLikeType(t);
54499
55072
  if (baseType.flags & 1048576 /* Union */) {
54500
55073
  const count = baseType.types.length;
@@ -87439,6 +88012,9 @@ function createTypeChecker(host) {
87439
88012
  tracker.trackSymbol(name, enclosing, 111551 /* Value */);
87440
88013
  }
87441
88014
  }
88015
+ },
88016
+ symbolToDeclarations: (symbol, meaning, flags, verbosityLevel, out) => {
88017
+ return nodeBuilder.symbolToDeclarations(symbol, meaning, flags, verbosityLevel, out);
87442
88018
  }
87443
88019
  };
87444
88020
  function isImportRequiredByAugmentation(node) {
@@ -115342,7 +115918,8 @@ var notImplementedResolver = {
115342
115918
  getDeclarationStatementsForSourceFile: notImplemented,
115343
115919
  isImportRequiredByAugmentation: notImplemented,
115344
115920
  isDefinitelyReferenceToGlobalSymbolObject: notImplemented,
115345
- createLateBoundIndexSignatures: notImplemented
115921
+ createLateBoundIndexSignatures: notImplemented,
115922
+ symbolToDeclarations: notImplemented
115346
115923
  };
115347
115924
  var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
115348
115925
  var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));