@typescript-deploys/pr-build 5.9.0-pr-61505-16 → 5.9.0-pr-61589-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/_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.20250417`;
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,
@@ -50298,7 +50368,7 @@ function createTypeChecker(host) {
50298
50368
  return writer2;
50299
50369
  }
50300
50370
  }
50301
- function signatureToString(signature, enclosingDeclaration, flags = 0 /* None */, kind, writer) {
50371
+ function signatureToString(signature, enclosingDeclaration, flags = 0 /* None */, kind, writer, verbosityLevel, out) {
50302
50372
  return writer ? signatureToStringWorker(writer).getText() : usingSingleLineStringWriter(signatureToStringWorker);
50303
50373
  function signatureToStringWorker(writer2) {
50304
50374
  let sigOutput;
@@ -50307,7 +50377,18 @@ function createTypeChecker(host) {
50307
50377
  } else {
50308
50378
  sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructSignature */ : 179 /* CallSignature */;
50309
50379
  }
50310
- 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
+ );
50311
50392
  const printer = createPrinterWithRemoveCommentsOmitTrailingSemicolon();
50312
50393
  const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration);
50313
50394
  printer.writeNode(
@@ -50320,14 +50401,18 @@ function createTypeChecker(host) {
50320
50401
  return writer2;
50321
50402
  }
50322
50403
  }
50323
- 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) {
50324
50405
  const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */;
50325
50406
  const typeNode = nodeBuilder.typeToTypeNode(
50326
50407
  type,
50327
50408
  enclosingDeclaration,
50328
- toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0 /* None */),
50409
+ toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0),
50329
50410
  /*internalFlags*/
50330
- void 0
50411
+ void 0,
50412
+ /*tracker*/
50413
+ void 0,
50414
+ verbosityLevel,
50415
+ out
50331
50416
  );
50332
50417
  if (typeNode === void 0) return Debug.fail("should always get typenode");
50333
50418
  const printer = type !== unresolvedType ? createPrinterWithRemoveComments() : createPrinterWithDefaults();
@@ -50406,7 +50491,6 @@ function createTypeChecker(host) {
50406
50491
  },
50407
50492
  isOptionalParameter,
50408
50493
  isUndefinedIdentifierExpression(node) {
50409
- Debug.assert(isExpressionNode(node));
50410
50494
  return getSymbolAtLocation(node) === undefinedSymbol;
50411
50495
  },
50412
50496
  isEntityNameVisible(context, entityName, shouldComputeAliasToMakeVisible) {
@@ -50558,31 +50642,120 @@ function createTypeChecker(host) {
50558
50642
  };
50559
50643
  return {
50560
50644
  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))
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
50586
50759
  };
50587
50760
  function getTypeFromTypeNode2(context, node, noMappedTypes) {
50588
50761
  const type = getTypeFromTypeNodeWithoutContext(node);
@@ -50624,7 +50797,75 @@ function createTypeChecker(host) {
50624
50797
  }
50625
50798
  return symbolToExpression(symbol, context, meaning);
50626
50799
  }
50627
- 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) {
50628
50869
  const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : (internalFlags || 0 /* None */) & 4 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
50629
50870
  const context = {
50630
50871
  enclosingDeclaration,
@@ -50632,6 +50873,7 @@ function createTypeChecker(host) {
50632
50873
  flags: flags || 0 /* None */,
50633
50874
  internalFlags: internalFlags || 0 /* None */,
50634
50875
  tracker: void 0,
50876
+ maxExpansionDepth: verbosityLevel ?? -1,
50635
50877
  encounteredError: false,
50636
50878
  suppressReportInferenceFallback: false,
50637
50879
  reportedDiagnostic: false,
@@ -50653,13 +50895,23 @@ function createTypeChecker(host) {
50653
50895
  typeParameterNamesByText: void 0,
50654
50896
  typeParameterNamesByTextNextNameCount: void 0,
50655
50897
  enclosingSymbolTypes: /* @__PURE__ */ new Map(),
50656
- mapper: void 0
50898
+ mapper: void 0,
50899
+ depth: 0,
50900
+ typeStack: [],
50901
+ out: {
50902
+ canIncreaseExpansionDepth: false,
50903
+ truncated: false
50904
+ }
50657
50905
  };
50658
50906
  context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
50659
50907
  const resultingNode = cb(context);
50660
50908
  if (context.truncating && context.flags & 1 /* NoTruncation */) {
50661
50909
  context.tracker.reportTruncationError();
50662
50910
  }
50911
+ if (out) {
50912
+ out.canIncreaseExpansionDepth = context.out.canIncreaseExpansionDepth;
50913
+ out.truncated = context.out.truncated;
50914
+ }
50663
50915
  return context.encounteredError ? void 0 : resultingNode;
50664
50916
  }
50665
50917
  function addSymbolTypeToContext(context, symbol, type) {
@@ -50678,19 +50930,49 @@ function createTypeChecker(host) {
50678
50930
  function saveRestoreFlags(context) {
50679
50931
  const flags = context.flags;
50680
50932
  const internalFlags = context.internalFlags;
50933
+ const depth = context.depth;
50681
50934
  return restore;
50682
50935
  function restore() {
50683
50936
  context.flags = flags;
50684
50937
  context.internalFlags = internalFlags;
50938
+ context.depth = depth;
50685
50939
  }
50686
50940
  }
50941
+ function checkTruncationLengthIfExpanding(context) {
50942
+ return context.maxExpansionDepth >= 0 && checkTruncationLength(context);
50943
+ }
50687
50944
  function checkTruncationLength(context) {
50688
50945
  if (context.truncating) return context.truncating;
50689
50946
  return context.truncating = context.approximateLength > (context.flags & 1 /* NoTruncation */ ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
50690
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
+ }
50691
50971
  function typeToTypeNodeHelper(type, context) {
50692
50972
  const restoreFlags = saveRestoreFlags(context);
50973
+ if (type) context.typeStack.push(type.id);
50693
50974
  const typeNode = typeToTypeNodeWorker(type, context);
50975
+ if (type) context.typeStack.pop();
50694
50976
  restoreFlags();
50695
50977
  return typeNode;
50696
50978
  }
@@ -50701,6 +50983,7 @@ function createTypeChecker(host) {
50701
50983
  }
50702
50984
  const inTypeAlias = context.flags & 8388608 /* InTypeAlias */;
50703
50985
  context.flags &= ~8388608 /* InTypeAlias */;
50986
+ let expandingEnum = false;
50704
50987
  if (!type) {
50705
50988
  if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) {
50706
50989
  context.encounteredError = true;
@@ -50768,7 +51051,11 @@ function createTypeChecker(host) {
50768
51051
  return Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
50769
51052
  }
50770
51053
  }
50771
- 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
+ }
50772
51059
  }
50773
51060
  if (type.flags & 128 /* StringLiteral */) {
50774
51061
  context.approximateLength += type.value.length + 2;
@@ -50835,16 +51122,34 @@ function createTypeChecker(host) {
50835
51122
  return factory.createThisTypeNode();
50836
51123
  }
50837
51124
  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]);
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);
50842
51137
  }
50843
- return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
51138
+ context.depth += 1;
50844
51139
  }
50845
51140
  const objectFlags = getObjectFlags(type);
50846
51141
  if (objectFlags & 4 /* Reference */) {
50847
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
+ }
50848
51153
  return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
50849
51154
  }
50850
51155
  if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
@@ -50874,6 +51179,16 @@ function createTypeChecker(host) {
50874
51179
  void 0
50875
51180
  );
50876
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
+ }
50877
51192
  if (type.symbol) {
50878
51193
  return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
50879
51194
  }
@@ -50888,7 +51203,7 @@ function createTypeChecker(host) {
50888
51203
  type = type.origin;
50889
51204
  }
50890
51205
  if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
50891
- const types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types;
51206
+ const types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types, expandingEnum) : type.types;
50892
51207
  if (length(types) === 1) {
50893
51208
  return typeToTypeNodeHelper(types[0], context);
50894
51209
  }
@@ -51077,7 +51392,7 @@ function createTypeChecker(host) {
51077
51392
  }
51078
51393
  return result;
51079
51394
  }
51080
- function createAnonymousTypeNode(type2) {
51395
+ function createAnonymousTypeNode(type2, forceClassExpansion = false, forceExpansion = false) {
51081
51396
  var _a2, _b2;
51082
51397
  const typeId = type2.id;
51083
51398
  const symbol = type2.symbol;
@@ -51100,15 +51415,20 @@ function createTypeChecker(host) {
51100
51415
  const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
51101
51416
  if (isJSConstructor(symbol.valueDeclaration)) {
51102
51417
  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(
51418
+ } else if (!forceExpansion && (symbol.flags & 32 /* Class */ && !forceClassExpansion && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
51104
51419
  symbol,
51105
51420
  context.enclosingDeclaration,
51106
51421
  isInstanceType,
51107
51422
  /*shouldComputeAliasesToMakeVisible*/
51108
51423
  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)) {
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)) {
51112
51432
  const typeAlias = getTypeAliasForTypeLiteral(type2);
51113
51433
  if (typeAlias) {
51114
51434
  return symbolToTypeNode(typeAlias, context, 788968 /* Type */);
@@ -51144,7 +51464,7 @@ function createTypeChecker(host) {
51144
51464
  if (id && !context.symbolDepth) {
51145
51465
  context.symbolDepth = /* @__PURE__ */ new Map();
51146
51466
  }
51147
- const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
51467
+ const links = context.maxExpansionDepth >= 0 ? void 0 : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
51148
51468
  const key = `${getTypeId(type2)}|${context.flags}|${context.internalFlags}`;
51149
51469
  if (links) {
51150
51470
  links.serializedTypes || (links.serializedTypes = /* @__PURE__ */ new Map());
@@ -51461,6 +51781,7 @@ function createTypeChecker(host) {
51461
51781
  }
51462
51782
  function createTypeNodesFromResolvedType(resolvedType) {
51463
51783
  if (checkTruncationLength(context)) {
51784
+ context.out.truncated = true;
51464
51785
  if (context.flags & 1 /* NoTruncation */) {
51465
51786
  return [addSyntheticTrailingComment(factory.createNotEmittedTypeElement(), 3 /* MultiLineCommentTrivia */, "elided")];
51466
51787
  }
@@ -51474,6 +51795,7 @@ function createTypeChecker(host) {
51474
51795
  void 0
51475
51796
  )];
51476
51797
  }
51798
+ context.typeStack.push(-1);
51477
51799
  const typeElements = [];
51478
51800
  for (const signature of resolvedType.callSignatures) {
51479
51801
  typeElements.push(signatureToSignatureDeclarationHelper(signature, 179 /* CallSignature */, context));
@@ -51487,10 +51809,14 @@ function createTypeChecker(host) {
51487
51809
  }
51488
51810
  const properties = resolvedType.properties;
51489
51811
  if (!properties) {
51812
+ context.typeStack.pop();
51490
51813
  return typeElements;
51491
51814
  }
51492
51815
  let i = 0;
51493
51816
  for (const propertySymbol of properties) {
51817
+ if (isExpanding(context) && propertySymbol.flags & 4194304 /* Prototype */) {
51818
+ continue;
51819
+ }
51494
51820
  i++;
51495
51821
  if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) {
51496
51822
  if (propertySymbol.flags & 4194304 /* Prototype */) {
@@ -51501,6 +51827,7 @@ function createTypeChecker(host) {
51501
51827
  }
51502
51828
  }
51503
51829
  if (checkTruncationLength(context) && i + 2 < properties.length - 1) {
51830
+ context.out.truncated = true;
51504
51831
  if (context.flags & 1 /* NoTruncation */) {
51505
51832
  const typeElement = typeElements.pop();
51506
51833
  typeElements.push(addSyntheticTrailingComment(typeElement, 3 /* MultiLineCommentTrivia */, `... ${properties.length - i} more elided ...`));
@@ -51520,6 +51847,7 @@ function createTypeChecker(host) {
51520
51847
  }
51521
51848
  addPropertyToElementList(propertySymbol, context, typeElements);
51522
51849
  }
51850
+ context.typeStack.pop();
51523
51851
  return typeElements.length ? typeElements : void 0;
51524
51852
  }
51525
51853
  }
@@ -51668,6 +51996,7 @@ function createTypeChecker(host) {
51668
51996
  function mapToTypeNodes(types, context, isBareList) {
51669
51997
  if (some(types)) {
51670
51998
  if (checkTruncationLength(context)) {
51999
+ context.out.truncated = true;
51671
52000
  if (!isBareList) {
51672
52001
  return [
51673
52002
  context.flags & 1 /* NoTruncation */ ? addSyntheticLeadingComment(factory.createKeywordTypeNode(133 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "elided") : factory.createTypeReferenceNode(
@@ -51695,6 +52024,7 @@ function createTypeChecker(host) {
51695
52024
  for (const type of types) {
51696
52025
  i++;
51697
52026
  if (checkTruncationLength(context) && i + 2 < types.length - 1) {
52027
+ context.out.truncated = true;
51698
52028
  result.push(
51699
52029
  context.flags & 1 /* NoTruncation */ ? addSyntheticLeadingComment(factory.createKeywordTypeNode(133 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, `... ${types.length - i} more elided ...`) : factory.createTypeReferenceNode(
51700
52030
  `... ${types.length - i} more ...`,
@@ -52092,7 +52422,7 @@ function createTypeChecker(host) {
52092
52422
  return factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
52093
52423
  }
52094
52424
  function typeToTypeNodeHelperWithPossibleReusableTypeNode(type, typeNode, context) {
52095
- 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);
52096
52426
  }
52097
52427
  function typeParameterToDeclaration(type, context, constraint = getConstraintOfTypeParameter(type)) {
52098
52428
  const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context);
@@ -52611,12 +52941,15 @@ function createTypeChecker(host) {
52611
52941
  }
52612
52942
  let firstChar = symbolName2.charCodeAt(0);
52613
52943
  if (isSingleOrDoubleQuote(firstChar) && some(symbol2.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
52614
- return factory.createStringLiteral(getSpecifierForModuleSymbol(symbol2, context));
52944
+ const specifier = getSpecifierForModuleSymbol(symbol2, context);
52945
+ context.approximateLength += 2 + specifier.length;
52946
+ return factory.createStringLiteral(specifier);
52615
52947
  }
52616
52948
  if (index === 0 || canUsePropertyAccess(symbolName2, languageVersion)) {
52617
52949
  const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
52618
52950
  if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
52619
52951
  identifier.symbol = symbol2;
52952
+ context.approximateLength += 1 + symbolName2.length;
52620
52953
  return index > 0 ? factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), identifier) : identifier;
52621
52954
  } else {
52622
52955
  if (firstChar === 91 /* openBracket */) {
@@ -52625,16 +52958,21 @@ function createTypeChecker(host) {
52625
52958
  }
52626
52959
  let expression;
52627
52960
  if (isSingleOrDoubleQuote(firstChar) && !(symbol2.flags & 8 /* EnumMember */)) {
52628
- 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 */);
52629
52964
  } else if ("" + +symbolName2 === symbolName2) {
52965
+ context.approximateLength += symbolName2.length;
52630
52966
  expression = factory.createNumericLiteral(+symbolName2);
52631
52967
  }
52632
52968
  if (!expression) {
52633
52969
  const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
52634
52970
  if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
52635
52971
  identifier.symbol = symbol2;
52972
+ context.approximateLength += symbolName2.length;
52636
52973
  expression = identifier;
52637
52974
  }
52975
+ context.approximateLength += 2;
52638
52976
  return factory.createElementAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), expression);
52639
52977
  }
52640
52978
  }
@@ -52663,6 +53001,10 @@ function createTypeChecker(host) {
52663
53001
  ), "'")));
52664
53002
  }
52665
53003
  function getPropertyNameNodeForSymbol(symbol, context) {
53004
+ const hashPrivateName = getClonedHashPrivateName(symbol);
53005
+ if (hashPrivateName) {
53006
+ return hashPrivateName;
53007
+ }
52666
53008
  const stringNamed = !!length(symbol.declarations) && every(symbol.declarations, isStringNamed);
52667
53009
  const singleQuote = !!length(symbol.declarations) && every(symbol.declarations, isSingleQuotedStringNamed);
52668
53010
  const isMethod = !!(symbol.flags & 8192 /* Method */);
@@ -52739,7 +53081,7 @@ function createTypeChecker(host) {
52739
53081
  let result;
52740
53082
  const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
52741
53083
  const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
52742
- if (decl) {
53084
+ if (!canPossiblyExpandType(type, context) && decl) {
52743
53085
  const restore = addSymbolTypeToContext(context, symbol, type);
52744
53086
  if (isAccessor(decl)) {
52745
53087
  result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
@@ -52778,7 +53120,7 @@ function createTypeChecker(host) {
52778
53120
  let returnTypeNode;
52779
53121
  const returnType = getReturnTypeOfSignature(signature);
52780
53122
  if (!(suppressAny && isTypeAny(returnType))) {
52781
- if (signature.declaration && !nodeIsSynthesized(signature.declaration)) {
53123
+ if (signature.declaration && !nodeIsSynthesized(signature.declaration) && !canPossiblyExpandType(returnType, context)) {
52782
53124
  const declarationSymbol = getSymbolOfDeclaration(signature.declaration);
52783
53125
  const restore = addSymbolTypeToContext(context, declarationSymbol, returnType);
52784
53126
  returnTypeNode = syntacticNodeBuilder.serializeReturnTypeForSignature(signature.declaration, declarationSymbol, context);
@@ -53189,14 +53531,28 @@ function createTypeChecker(host) {
53189
53531
  if (!suppressNewPrivateContext) {
53190
53532
  deferredPrivatesStack.push(/* @__PURE__ */ new Map());
53191
53533
  }
53192
- 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
+ }
53193
53549
  serializeSymbol(
53194
53550
  symbol,
53195
53551
  /*isPrivate*/
53196
53552
  false,
53197
53553
  !!propertyAsAlias
53198
53554
  );
53199
- });
53555
+ }
53200
53556
  if (!suppressNewPrivateContext) {
53201
53557
  deferredPrivatesStack[deferredPrivatesStack.length - 1].forEach((symbol) => {
53202
53558
  serializeSymbol(
@@ -53226,7 +53582,7 @@ function createTypeChecker(host) {
53226
53582
  }
53227
53583
  }
53228
53584
  function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias, escapedSymbolName = symbol.escapedName) {
53229
- var _a2, _b, _c, _d, _e, _f;
53585
+ var _a2, _b, _c, _d, _e, _f, _g;
53230
53586
  const symbolName2 = unescapeLeadingUnderscores(escapedSymbolName);
53231
53587
  const isDefault = escapedSymbolName === "default" /* Default */;
53232
53588
  if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && isStringANonContextualKeyword(symbolName2) && !isDefault) {
@@ -53276,6 +53632,7 @@ function createTypeChecker(host) {
53276
53632
  const propertyAccessRequire = (_e = symbol.declarations) == null ? void 0 : _e.find(isPropertyAccessExpression);
53277
53633
  if (propertyAccessRequire && isBinaryExpression(propertyAccessRequire.parent) && isIdentifier(propertyAccessRequire.parent.right) && ((_f = type.symbol) == null ? void 0 : _f.valueDeclaration) && isSourceFile(type.symbol.valueDeclaration)) {
53278
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);
53279
53636
  addResult(
53280
53637
  factory.createExportDeclaration(
53281
53638
  /*modifiers*/
@@ -53315,8 +53672,10 @@ function createTypeChecker(host) {
53315
53672
  ),
53316
53673
  textRange
53317
53674
  );
53675
+ context.approximateLength += 7 + name.length;
53318
53676
  addResult(statement, name !== localName ? modifierFlags & ~32 /* Export */ : modifierFlags);
53319
53677
  if (name !== localName && !isPrivate) {
53678
+ context.approximateLength += 16 + name.length + localName.length;
53320
53679
  addResult(
53321
53680
  factory.createExportDeclaration(
53322
53681
  /*modifiers*/
@@ -53366,27 +53725,33 @@ function createTypeChecker(host) {
53366
53725
  for (const node of symbol.declarations) {
53367
53726
  const resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
53368
53727
  if (!resolvedModule) continue;
53728
+ const isTypeOnly = node.isTypeOnly;
53729
+ const specifier = getSpecifierForModuleSymbol(resolvedModule, context);
53730
+ context.approximateLength += 17 + specifier.length;
53369
53731
  addResult(factory.createExportDeclaration(
53370
53732
  /*modifiers*/
53371
53733
  void 0,
53372
- /*isTypeOnly*/
53373
- node.isTypeOnly,
53734
+ isTypeOnly,
53374
53735
  /*exportClause*/
53375
53736
  void 0,
53376
- factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))
53737
+ factory.createStringLiteral(specifier)
53377
53738
  ), 0 /* None */);
53378
53739
  }
53379
53740
  }
53380
53741
  }
53381
53742
  if (needsPostExportDefault) {
53743
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53744
+ context.approximateLength += 16 + internalSymbolName.length;
53382
53745
  addResult(factory.createExportAssignment(
53383
53746
  /*modifiers*/
53384
53747
  void 0,
53385
53748
  /*isExportEquals*/
53386
53749
  false,
53387
- factory.createIdentifier(getInternalSymbolName(symbol, symbolName2))
53750
+ factory.createIdentifier(internalSymbolName)
53388
53751
  ), 0 /* None */);
53389
53752
  } else if (needsExportDeclaration) {
53753
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53754
+ context.approximateLength += 22 + symbolName2.length + internalSymbolName.length;
53390
53755
  addResult(
53391
53756
  factory.createExportDeclaration(
53392
53757
  /*modifiers*/
@@ -53396,7 +53761,7 @@ function createTypeChecker(host) {
53396
53761
  factory.createNamedExports([factory.createExportSpecifier(
53397
53762
  /*isTypeOnly*/
53398
53763
  false,
53399
- getInternalSymbolName(symbol, symbolName2),
53764
+ internalSymbolName,
53400
53765
  symbolName2
53401
53766
  )])
53402
53767
  ),
@@ -53416,6 +53781,7 @@ function createTypeChecker(host) {
53416
53781
  }
53417
53782
  function addResult(node, additionalModifierFlags) {
53418
53783
  if (canHaveModifiers(node)) {
53784
+ const oldModifierFlags = getEffectiveModifierFlags(node);
53419
53785
  let newModifierFlags = 0 /* None */;
53420
53786
  const enclosingDeclaration2 = context.enclosingDeclaration && (isJSDocTypeAlias(context.enclosingDeclaration) ? getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
53421
53787
  if (additionalModifierFlags & 32 /* Export */ && enclosingDeclaration2 && (isExportingScope(enclosingDeclaration2) || isModuleDeclaration(enclosingDeclaration2)) && canHaveExportModifier(node)) {
@@ -53428,8 +53794,9 @@ function createTypeChecker(host) {
53428
53794
  newModifierFlags |= 2048 /* Default */;
53429
53795
  }
53430
53796
  if (newModifierFlags) {
53431
- node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node));
53797
+ node = factory.replaceModifiers(node, newModifierFlags | oldModifierFlags);
53432
53798
  }
53799
+ context.approximateLength += modifiersLength(newModifierFlags | oldModifierFlags);
53433
53800
  }
53434
53801
  results.push(node);
53435
53802
  }
@@ -53445,12 +53812,14 @@ function createTypeChecker(host) {
53445
53812
  const oldEnclosingDecl = context.enclosingDeclaration;
53446
53813
  context.enclosingDeclaration = jsdocAliasDecl;
53447
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;
53448
53817
  addResult(
53449
53818
  setSyntheticLeadingComments(
53450
53819
  factory.createTypeAliasDeclaration(
53451
53820
  /*modifiers*/
53452
53821
  void 0,
53453
- getInternalSymbolName(symbol, symbolName2),
53822
+ internalSymbolName,
53454
53823
  typeParamDecls,
53455
53824
  typeNode
53456
53825
  ),
@@ -53462,12 +53831,19 @@ function createTypeChecker(host) {
53462
53831
  context.enclosingDeclaration = oldEnclosingDecl;
53463
53832
  }
53464
53833
  function serializeInterface(symbol, symbolName2, modifierFlags) {
53834
+ const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
53835
+ context.approximateLength += 14 + internalSymbolName.length;
53465
53836
  const interfaceType = getDeclaredTypeOfClassOrInterface(symbol);
53466
53837
  const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
53467
53838
  const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
53468
53839
  const baseTypes = getBaseTypes(interfaceType);
53469
53840
  const baseType = length(baseTypes) ? getIntersectionType(baseTypes) : void 0;
53470
- const members = flatMap(getPropertiesOfType(interfaceType), (p) => serializePropertySymbolForInterface(p, baseType));
53841
+ const members = serializePropertySymbolsForClassOrInterface(
53842
+ getPropertiesOfType(interfaceType),
53843
+ /*isClass*/
53844
+ false,
53845
+ baseType
53846
+ );
53471
53847
  const callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 179 /* CallSignature */);
53472
53848
  const constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 180 /* ConstructSignature */);
53473
53849
  const indexSignatures = serializeIndexSignatures(interfaceType, baseType);
@@ -53476,7 +53852,7 @@ function createTypeChecker(host) {
53476
53852
  factory.createInterfaceDeclaration(
53477
53853
  /*modifiers*/
53478
53854
  void 0,
53479
- getInternalSymbolName(symbol, symbolName2),
53855
+ internalSymbolName,
53480
53856
  typeParamDecls,
53481
53857
  heritageClauses,
53482
53858
  [...indexSignatures, ...constructSignatures, ...callSignatures, ...members]
@@ -53484,6 +53860,57 @@ function createTypeChecker(host) {
53484
53860
  modifierFlags
53485
53861
  );
53486
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
+ }
53487
53914
  function getNamespaceMembersForSerialization(symbol) {
53488
53915
  let exports2 = arrayFrom(getExportsOfSymbol(symbol).values());
53489
53916
  const merged = getMergedSymbol(symbol);
@@ -53503,11 +53930,27 @@ function createTypeChecker(host) {
53503
53930
  }
53504
53931
  function serializeModule(symbol, symbolName2, modifierFlags) {
53505
53932
  const members = getNamespaceMembersForSerialization(symbol);
53506
- 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");
53507
53935
  const realMembers = locationMap.get("real") || emptyArray;
53508
53936
  const mergedMembers = locationMap.get("merged") || emptyArray;
53509
- if (length(realMembers)) {
53510
- 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
+ }
53511
53954
  serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */)));
53512
53955
  }
53513
53956
  if (length(mergedMembers)) {
@@ -53555,17 +53998,51 @@ function createTypeChecker(host) {
53555
53998
  }
53556
53999
  }
53557
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
+ }
53558
54041
  addResult(
53559
54042
  factory.createEnumDeclaration(
53560
54043
  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
- })
54044
+ internalSymbolName,
54045
+ members
53569
54046
  ),
53570
54047
  modifierFlags
53571
54048
  );
@@ -53573,20 +54050,28 @@ function createTypeChecker(host) {
53573
54050
  function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
53574
54051
  const signatures = getSignaturesOfType(type, 0 /* Call */);
53575
54052
  for (const sig of signatures) {
54053
+ context.approximateLength += 1;
53576
54054
  const decl = signatureToSignatureDeclarationHelper(sig, 262 /* FunctionDeclaration */, context, { name: factory.createIdentifier(localName) });
53577
54055
  addResult(setTextRange2(context, decl, getSignatureTextRangeLocation(sig)), modifierFlags);
53578
54056
  }
53579
54057
  if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) {
53580
54058
  const props = filter(getPropertiesOfType(type), isNamespaceMember);
54059
+ context.approximateLength += localName.length;
53581
54060
  serializeAsNamespaceDeclaration(
53582
54061
  props,
53583
- localName,
54062
+ factory.createIdentifier(localName),
53584
54063
  modifierFlags,
53585
54064
  /*suppressNewPrivateContext*/
53586
54065
  true
53587
54066
  );
53588
54067
  }
53589
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
+ }
53590
54075
  function getSignatureTextRangeLocation(signature) {
53591
54076
  if (signature.declaration && signature.declaration.parent) {
53592
54077
  if (isBinaryExpression(signature.declaration.parent) && getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) {
@@ -53599,15 +54084,18 @@ function createTypeChecker(host) {
53599
54084
  return signature.declaration;
53600
54085
  }
53601
54086
  function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) {
54087
+ const nodeFlags = isIdentifier(localName) ? 32 /* Namespace */ : 0 /* None */;
54088
+ const expanding = isExpanding(context);
53602
54089
  if (length(props)) {
53603
- 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");
53604
54092
  const localProps = localVsRemoteMap.get("local") || emptyArray;
53605
54093
  let fakespace = parseNodeFactory.createModuleDeclaration(
53606
54094
  /*modifiers*/
53607
54095
  void 0,
53608
- factory.createIdentifier(localName),
54096
+ localName,
53609
54097
  factory.createModuleBlock([]),
53610
- 32 /* Namespace */
54098
+ nodeFlags
53611
54099
  );
53612
54100
  setParent(fakespace, enclosingDeclaration);
53613
54101
  fakespace.locals = createSymbolTable(props);
@@ -53649,6 +54137,18 @@ function createTypeChecker(host) {
53649
54137
  factory.createModuleBlock(exportModifierStripped)
53650
54138
  );
53651
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
+ );
53652
54152
  }
53653
54153
  }
53654
54154
  function isNamespaceMember(p) {
@@ -53691,11 +54191,13 @@ function createTypeChecker(host) {
53691
54191
  }
53692
54192
  function serializeAsClass(symbol, localName, modifierFlags) {
53693
54193
  var _a2, _b;
54194
+ context.approximateLength += 9 + localName.length;
53694
54195
  const originalDecl = (_a2 = symbol.declarations) == null ? void 0 : _a2.find(isClassLike);
53695
54196
  const oldEnclosing = context.enclosingDeclaration;
53696
54197
  context.enclosingDeclaration = originalDecl || oldEnclosing;
53697
54198
  const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
53698
54199
  const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
54200
+ forEach(localParams, (p) => context.approximateLength += symbolName(p.symbol).length);
53699
54201
  const classType = getTypeWithThisArgument(getDeclaredTypeOfClassOrInterface(symbol));
53700
54202
  const baseTypes = getBaseTypes(classType);
53701
54203
  const originalImplements = originalDecl && getEffectiveImplementsTypeNodes(originalDecl);
@@ -53703,20 +54205,22 @@ function createTypeChecker(host) {
53703
54205
  const staticType = getTypeOfSymbol(symbol);
53704
54206
  const isClass = !!((_b = staticType.symbol) == null ? void 0 : _b.valueDeclaration) && isClassLike(staticType.symbol.valueDeclaration);
53705
54207
  const staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType;
54208
+ context.approximateLength += (length(baseTypes) ? 8 : 0) + (length(implementsExpressions) ? 11 : 0);
53706
54209
  const heritageClauses = [
53707
54210
  ...!length(baseTypes) ? [] : [factory.createHeritageClause(96 /* ExtendsKeyword */, map(baseTypes, (b) => serializeBaseType(b, staticBaseType, localName)))],
53708
54211
  ...!length(implementsExpressions) ? [] : [factory.createHeritageClause(119 /* ImplementsKeyword */, implementsExpressions)]
53709
54212
  ];
53710
54213
  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(
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(
53720
54224
  /*modifiers*/
53721
54225
  void 0,
53722
54226
  factory.createPrivateIdentifier("#private"),
@@ -53727,22 +54231,27 @@ function createTypeChecker(host) {
53727
54231
  /*initializer*/
53728
54232
  void 0
53729
54233
  )] : emptyArray;
53730
- const publicProperties = flatMap(publicSymbolProps, (p) => serializePropertySymbolForClass(
53731
- p,
54234
+ if (hasPrivateIdentifier && !isExpanding(context)) {
54235
+ context.approximateLength += 9;
54236
+ }
54237
+ const publicProperties = serializePropertySymbolsForClassOrInterface(
54238
+ publicSymbolProps,
54239
+ /*isClass*/
54240
+ true,
54241
+ baseTypes[0],
53732
54242
  /*isStatic*/
53733
- false,
53734
- baseTypes[0]
53735
- ));
53736
- const staticMembers = flatMap(
54243
+ false
54244
+ );
54245
+ const staticMembers = serializePropertySymbolsForClassOrInterface(
53737
54246
  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
- )
54247
+ /*isClass*/
54248
+ true,
54249
+ staticBaseType,
54250
+ /*isStatic*/
54251
+ true
53744
54252
  );
53745
54253
  const isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && !some(getSignaturesOfType(staticType, 1 /* Construct */));
54254
+ if (isNonConstructableClassLikeInJsFile) context.approximateLength += 21;
53746
54255
  const constructors = isNonConstructableClassLikeInJsFile ? [factory.createConstructorDeclaration(
53747
54256
  factory.createModifiersFromModifierFlags(2 /* Private */),
53748
54257
  [],
@@ -53810,6 +54319,8 @@ function createTypeChecker(host) {
53810
54319
  if (((_b = (_a2 = node.parent) == null ? void 0 : _a2.parent) == null ? void 0 : _b.kind) === 260 /* VariableDeclaration */) {
53811
54320
  const specifier2 = getSpecifierForModuleSymbol(target.parent || target, context);
53812
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);
53813
54324
  addResult(
53814
54325
  factory.createImportDeclaration(
53815
54326
  /*modifiers*/
@@ -53822,7 +54333,7 @@ function createTypeChecker(host) {
53822
54333
  factory.createNamedImports([factory.createImportSpecifier(
53823
54334
  /*isTypeOnly*/
53824
54335
  false,
53825
- propertyName && isIdentifier(propertyName) ? factory.createIdentifier(idText(propertyName)) : void 0,
54336
+ propertyNameText ? factory.createIdentifier(propertyNameText) : void 0,
53826
54337
  factory.createIdentifier(localName)
53827
54338
  )])
53828
54339
  ),
@@ -53849,6 +54360,7 @@ function createTypeChecker(host) {
53849
54360
  const initializer = node.initializer;
53850
54361
  const uniqueName = factory.createUniqueName(localName);
53851
54362
  const specifier2 = getSpecifierForModuleSymbol(target.parent || target, context);
54363
+ context.approximateLength += 22 + specifier2.length + idText(uniqueName).length;
53852
54364
  addResult(
53853
54365
  factory.createImportEqualsDeclaration(
53854
54366
  /*modifiers*/
@@ -53860,6 +54372,7 @@ function createTypeChecker(host) {
53860
54372
  ),
53861
54373
  0 /* None */
53862
54374
  );
54375
+ context.approximateLength += 12 + localName.length + idText(uniqueName).length + idText(initializer.name).length;
53863
54376
  addResult(
53864
54377
  factory.createImportEqualsDeclaration(
53865
54378
  /*modifiers*/
@@ -53880,6 +54393,7 @@ function createTypeChecker(host) {
53880
54393
  break;
53881
54394
  }
53882
54395
  const isLocalImport = !(target.flags & 512 /* ValueModule */) && !isVariableDeclaration(node);
54396
+ context.approximateLength += 11 + localName.length + unescapeLeadingUnderscores(target.escapedName).length;
53883
54397
  addResult(
53884
54398
  factory.createImportEqualsDeclaration(
53885
54399
  /*modifiers*/
@@ -53906,6 +54420,7 @@ function createTypeChecker(host) {
53906
54420
  const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
53907
54421
  const attributes = isImportDeclaration(node.parent) ? node.parent.attributes : void 0;
53908
54422
  const isTypeOnly = isJSDocImportTag(node.parent);
54423
+ context.approximateLength += 14 + localName.length + 3 + (isTypeOnly ? 4 : 0);
53909
54424
  addResult(
53910
54425
  factory.createImportDeclaration(
53911
54426
  /*modifiers*/
@@ -53927,6 +54442,7 @@ function createTypeChecker(host) {
53927
54442
  const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
53928
54443
  const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
53929
54444
  const isTypeOnly = isJSDocImportTag(node.parent.parent);
54445
+ context.approximateLength += 19 + localName.length + 3 + (isTypeOnly ? 4 : 0);
53930
54446
  addResult(
53931
54447
  factory.createImportDeclaration(
53932
54448
  /*modifiers*/
@@ -53945,6 +54461,7 @@ function createTypeChecker(host) {
53945
54461
  break;
53946
54462
  }
53947
54463
  case 280 /* NamespaceExport */:
54464
+ context.approximateLength += 19 + localName.length + 3;
53948
54465
  addResult(
53949
54466
  factory.createExportDeclaration(
53950
54467
  /*modifiers*/
@@ -53961,6 +54478,7 @@ function createTypeChecker(host) {
53961
54478
  const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
53962
54479
  const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
53963
54480
  const isTypeOnly = isJSDocImportTag(node.parent.parent.parent);
54481
+ context.approximateLength += 19 + localName.length + 3 + (isTypeOnly ? 4 : 0);
53964
54482
  addResult(
53965
54483
  factory.createImportDeclaration(
53966
54484
  /*modifiers*/
@@ -54016,6 +54534,7 @@ function createTypeChecker(host) {
54016
54534
  }
54017
54535
  }
54018
54536
  function serializeExportSpecifier(localName, targetName, specifier) {
54537
+ context.approximateLength += 16 + localName.length + (localName !== targetName ? targetName.length : 0);
54019
54538
  addResult(
54020
54539
  factory.createExportDeclaration(
54021
54540
  /*modifiers*/
@@ -54066,6 +54585,7 @@ function createTypeChecker(host) {
54066
54585
  const prevDisableTrackSymbol = context.tracker.disableTrackSymbol;
54067
54586
  context.tracker.disableTrackSymbol = true;
54068
54587
  if (isExportAssignmentCompatibleSymbolName) {
54588
+ context.approximateLength += 10;
54069
54589
  results.push(factory.createExportAssignment(
54070
54590
  /*modifiers*/
54071
54591
  void 0,
@@ -54079,6 +54599,7 @@ function createTypeChecker(host) {
54079
54599
  serializeExportSpecifier(name, getInternalSymbolName(target, symbolName(target)));
54080
54600
  } else {
54081
54601
  const varName = getUnusedName(name, symbol);
54602
+ context.approximateLength += varName.length + 10;
54082
54603
  addResult(
54083
54604
  factory.createImportEqualsDeclaration(
54084
54605
  /*modifiers*/
@@ -54108,6 +54629,7 @@ function createTypeChecker(host) {
54108
54629
  serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 32 /* Export */);
54109
54630
  } else {
54110
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;
54111
54633
  const statement = factory.createVariableStatement(
54112
54634
  /*modifiers*/
54113
54635
  void 0,
@@ -54132,6 +54654,7 @@ function createTypeChecker(host) {
54132
54654
  );
54133
54655
  }
54134
54656
  if (isExportAssignmentCompatibleSymbolName) {
54657
+ context.approximateLength += varName.length + 10;
54135
54658
  results.push(factory.createExportAssignment(
54136
54659
  /*modifiers*/
54137
54660
  void 0,
@@ -54166,7 +54689,7 @@ function createTypeChecker(host) {
54166
54689
  return function serializePropertySymbol(p, isStatic2, baseType) {
54167
54690
  var _a2, _b, _c, _d, _e, _f;
54168
54691
  const modifierFlags = getDeclarationModifierFlagsFromSymbol(p);
54169
- const isPrivate = !!(modifierFlags & 2 /* Private */);
54692
+ const omitType = !!(modifierFlags & 2 /* Private */) && !isExpanding(context);
54170
54693
  if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) {
54171
54694
  return [];
54172
54695
  }
@@ -54195,6 +54718,7 @@ function createTypeChecker(host) {
54195
54718
  Debug.assert(!!setter);
54196
54719
  const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : void 0;
54197
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);
54198
54722
  result.push(setTextRange2(
54199
54723
  context,
54200
54724
  factory.createSetAccessorDeclaration(
@@ -54208,7 +54732,7 @@ function createTypeChecker(host) {
54208
54732
  paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
54209
54733
  /*questionToken*/
54210
54734
  void 0,
54211
- isPrivate ? void 0 : serializeTypeForDeclaration(context, setterDeclaration, getWriteTypeOfSymbol(p), p)
54735
+ omitType ? void 0 : serializeTypeForDeclaration(context, setterDeclaration, getWriteTypeOfSymbol(p), p)
54212
54736
  )],
54213
54737
  /*body*/
54214
54738
  void 0
@@ -54217,15 +54741,15 @@ function createTypeChecker(host) {
54217
54741
  ));
54218
54742
  }
54219
54743
  if (p.flags & 32768 /* GetAccessor */) {
54220
- const isPrivate2 = modifierFlags & 2 /* Private */;
54221
54744
  const getterDeclaration = (_c = p.declarations) == null ? void 0 : _c.find(isGetAccessor);
54745
+ context.approximateLength += modifiersLength(flag) + 8 + (omitType ? 0 : 2);
54222
54746
  result.push(setTextRange2(
54223
54747
  context,
54224
54748
  factory.createGetAccessorDeclaration(
54225
54749
  factory.createModifiersFromModifierFlags(flag),
54226
54750
  name,
54227
54751
  [],
54228
- isPrivate2 ? void 0 : serializeTypeForDeclaration(context, getterDeclaration, getTypeOfSymbol(p), p),
54752
+ omitType ? void 0 : serializeTypeForDeclaration(context, getterDeclaration, getTypeOfSymbol(p), p),
54229
54753
  /*body*/
54230
54754
  void 0
54231
54755
  ),
@@ -54234,13 +54758,15 @@ function createTypeChecker(host) {
54234
54758
  }
54235
54759
  return result;
54236
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);
54237
54763
  return setTextRange2(
54238
54764
  context,
54239
54765
  createProperty2(
54240
- factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
54766
+ factory.createModifiersFromModifierFlags(modifierFlags2),
54241
54767
  name,
54242
54768
  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),
54769
+ omitType ? void 0 : serializeTypeForDeclaration(context, (_d = p.declarations) == null ? void 0 : _d.find(isSetAccessorDeclaration), getWriteTypeOfSymbol(p), p),
54244
54770
  // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357
54245
54771
  // interface members can't have initializers, however class members _can_
54246
54772
  /*initializer*/
@@ -54252,11 +54778,13 @@ function createTypeChecker(host) {
54252
54778
  if (p.flags & (8192 /* Method */ | 16 /* Function */)) {
54253
54779
  const type = getTypeOfSymbol(p);
54254
54780
  const signatures = getSignaturesOfType(type, 0 /* Call */);
54255
- if (flag & 2 /* Private */) {
54781
+ if (omitType) {
54782
+ const modifierFlags2 = (isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag;
54783
+ context.approximateLength += 1 + modifiersLength(modifierFlags2);
54256
54784
  return setTextRange2(
54257
54785
  context,
54258
54786
  createProperty2(
54259
- factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
54787
+ factory.createModifiersFromModifierFlags(modifierFlags2),
54260
54788
  name,
54261
54789
  p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
54262
54790
  /*type*/
@@ -54269,6 +54797,7 @@ function createTypeChecker(host) {
54269
54797
  }
54270
54798
  const results2 = [];
54271
54799
  for (const sig of signatures) {
54800
+ context.approximateLength += 1;
54272
54801
  const decl = signatureToSignatureDeclarationHelper(
54273
54802
  sig,
54274
54803
  methodKind,
@@ -54287,6 +54816,25 @@ function createTypeChecker(host) {
54287
54816
  return Debug.fail(`Unhandled class member kind! ${p.__debugFlags || p.flags}`);
54288
54817
  };
54289
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
+ }
54290
54838
  function serializePropertySymbolForInterface(p, baseType) {
54291
54839
  return serializePropertySymbolForInterfaceWorker(
54292
54840
  p,
@@ -54351,6 +54899,7 @@ function createTypeChecker(host) {
54351
54899
  }
54352
54900
  const results2 = [];
54353
54901
  for (const sig of signatures) {
54902
+ context.approximateLength += 1;
54354
54903
  const decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
54355
54904
  results2.push(setTextRange2(context, decl, sig.declaration));
54356
54905
  }
@@ -54476,6 +55025,23 @@ function createTypeChecker(host) {
54476
55025
  return localName;
54477
55026
  }
54478
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))));
54479
55045
  }
54480
55046
  function typePredicateToString(typePredicate, enclosingDeclaration, flags = 16384 /* UseAliasDefinedOutsideCurrentScope */, writer) {
54481
55047
  return writer ? typePredicateToStringWorker(writer).getText() : usingSingleLineStringWriter(typePredicateToStringWorker);
@@ -54494,14 +55060,14 @@ function createTypeChecker(host) {
54494
55060
  return writer2;
54495
55061
  }
54496
55062
  }
54497
- function formatUnionTypes(types) {
55063
+ function formatUnionTypes(types, expandingEnum) {
54498
55064
  const result = [];
54499
55065
  let flags = 0;
54500
55066
  for (let i = 0; i < types.length; i++) {
54501
55067
  const t = types[i];
54502
55068
  flags |= t.flags;
54503
55069
  if (!(t.flags & 98304 /* Nullable */)) {
54504
- if (t.flags & (512 /* BooleanLiteral */ | 1056 /* EnumLike */)) {
55070
+ if (t.flags & 512 /* BooleanLiteral */ || !expandingEnum && t.flags | 1056 /* EnumLike */) {
54505
55071
  const baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLikeType(t);
54506
55072
  if (baseType.flags & 1048576 /* Union */) {
54507
55073
  const count = baseType.types.length;
@@ -58584,7 +59150,7 @@ function createTypeChecker(host) {
58584
59150
  let hasThisParameter = false;
58585
59151
  const iife = getImmediatelyInvokedFunctionExpression(declaration);
58586
59152
  const isJSConstructSignature = isJSDocConstructSignature(declaration);
58587
- const isUntypedSignatureInJSFile = !iife && isInJSFile(declaration) && isValueSignatureDeclaration(declaration) && !hasJSDocParameterTags(declaration) && !getJSDocType(declaration) && !getContextualSignatureForFunctionLikeDeclaration(declaration);
59153
+ const isUntypedSignatureInJSFile = !iife && isInJSFile(declaration) && isValueSignatureDeclaration(declaration) && !hasJSDocParameterTags(declaration) && !some(declaration.parameters, (p) => !!getJSDocType(p)) && !getJSDocType(declaration) && !getContextualSignatureForFunctionLikeDeclaration(declaration);
58588
59154
  if (isUntypedSignatureInJSFile) {
58589
59155
  flags |= 32 /* IsUntypedSignatureInJSFile */;
58590
59156
  }
@@ -61698,7 +62264,7 @@ function createTypeChecker(host) {
61698
62264
  context.nonFixingMapper = combineTypeMappers(context.nonFixingMapper, mapper);
61699
62265
  }
61700
62266
  if (!checkTypeDeferred) {
61701
- inferTypes(context, context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
62267
+ inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
61702
62268
  }
61703
62269
  combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper;
61704
62270
  }
@@ -62707,7 +63273,7 @@ function createTypeChecker(host) {
62707
63273
  ) : type;
62708
63274
  }
62709
63275
  function instantiateTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
62710
- var _a, _b;
63276
+ var _a;
62711
63277
  if (!couldContainTypeVariables(type)) {
62712
63278
  return type;
62713
63279
  }
@@ -62716,16 +63282,10 @@ function createTypeChecker(host) {
62716
63282
  error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
62717
63283
  return errorType;
62718
63284
  }
62719
- const key = type.id + getAliasId(aliasSymbol, aliasTypeArguments);
62720
- const cached = (mapper.instantiations ?? (mapper.instantiations = /* @__PURE__ */ new Map())).get(key);
62721
- if (cached) {
62722
- return cached;
62723
- }
62724
63285
  totalInstantiationCount++;
62725
63286
  instantiationCount++;
62726
63287
  instantiationDepth++;
62727
63288
  const result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments);
62728
- (_b = mapper.instantiations) == null ? void 0 : _b.set(key, result);
62729
63289
  instantiationDepth--;
62730
63290
  return result;
62731
63291
  }
@@ -65348,7 +65908,7 @@ function createTypeChecker(host) {
65348
65908
  0 /* None */,
65349
65909
  isRelatedToWorker
65350
65910
  );
65351
- inferTypes(ctx, ctx.inferences, target2.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
65911
+ inferTypes(ctx.inferences, target2.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
65352
65912
  sourceExtends = instantiateType(sourceExtends, ctx.mapper);
65353
65913
  mapper = ctx.mapper;
65354
65914
  }
@@ -67228,7 +67788,7 @@ function createTypeChecker(host) {
67228
67788
  map(context.inferences, (inference, i) => () => {
67229
67789
  if (!inference.isFixed) {
67230
67790
  inferFromIntraExpressionSites(context);
67231
- clearCachedInferences(context, context.inferences);
67791
+ clearCachedInferences(context.inferences);
67232
67792
  inference.isFixed = true;
67233
67793
  }
67234
67794
  return getInferredType(context, i);
@@ -67243,10 +67803,7 @@ function createTypeChecker(host) {
67243
67803
  })
67244
67804
  );
67245
67805
  }
67246
- function clearCachedInferences(context, inferences) {
67247
- if (context) {
67248
- context.nonFixingMapper.instantiations = void 0;
67249
- }
67806
+ function clearCachedInferences(inferences) {
67250
67807
  for (const inference of inferences) {
67251
67808
  if (!inference.isFixed) {
67252
67809
  inference.inferredType = void 0;
@@ -67261,7 +67818,7 @@ function createTypeChecker(host) {
67261
67818
  for (const { node, type } of context.intraExpressionInferenceSites) {
67262
67819
  const contextualType = node.kind === 174 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType(node, 2 /* NoConstraints */);
67263
67820
  if (contextualType) {
67264
- inferTypes(context, context.inferences, type, contextualType);
67821
+ inferTypes(context.inferences, type, contextualType);
67265
67822
  }
67266
67823
  }
67267
67824
  context.intraExpressionInferenceSites = void 0;
@@ -67405,13 +67962,7 @@ function createTypeChecker(host) {
67405
67962
  const typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
67406
67963
  const templateType = getTemplateTypeFromMappedType(target);
67407
67964
  const inference = createInferenceInfo(typeParameter);
67408
- inferTypes(
67409
- /*context*/
67410
- void 0,
67411
- [inference],
67412
- sourceType,
67413
- templateType
67414
- );
67965
+ inferTypes([inference], sourceType, templateType);
67415
67966
  return getTypeFromInference(inference) || unknownType;
67416
67967
  }
67417
67968
  function inferReverseMappedType(source, target, constraint) {
@@ -67613,7 +68164,7 @@ function createTypeChecker(host) {
67613
68164
  function isTupleOfSelf(typeParameter, type) {
67614
68165
  return isTupleType(type) && getTupleElementType(type, 0) === getIndexedAccessType(typeParameter, getNumberLiteralType(0)) && !getTypeOfPropertyOfType(type, "1");
67615
68166
  }
67616
- function inferTypes(context, inferences, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
68167
+ function inferTypes(inferences, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
67617
68168
  let bivariant = false;
67618
68169
  let propagationType;
67619
68170
  let inferencePriority = 2048 /* MaxValue */;
@@ -67704,16 +68255,16 @@ function createTypeChecker(host) {
67704
68255
  if (contravariant && !bivariant) {
67705
68256
  if (!contains(inference.contraCandidates, candidate)) {
67706
68257
  inference.contraCandidates = append(inference.contraCandidates, candidate);
67707
- clearCachedInferences(context, inferences);
68258
+ clearCachedInferences(inferences);
67708
68259
  }
67709
68260
  } else if (!contains(inference.candidates, candidate)) {
67710
68261
  inference.candidates = append(inference.candidates, candidate);
67711
- clearCachedInferences(context, inferences);
68262
+ clearCachedInferences(inferences);
67712
68263
  }
67713
68264
  }
67714
68265
  if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
67715
68266
  inference.topLevel = false;
67716
- clearCachedInferences(context, inferences);
68267
+ clearCachedInferences(inferences);
67717
68268
  }
67718
68269
  }
67719
68270
  inferencePriority = Math.min(inferencePriority, priority);
@@ -68279,7 +68830,6 @@ function createTypeChecker(host) {
68279
68830
  const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
68280
68831
  if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
68281
68832
  inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
68282
- context.nonFixingMapper.instantiations = void 0;
68283
68833
  }
68284
68834
  }
68285
68835
  }
@@ -70295,15 +70845,31 @@ function createTypeChecker(host) {
70295
70845
  }
70296
70846
  const isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
70297
70847
  const keyPropertyName = type.flags & 1048576 /* Union */ ? getKeyPropertyName(type) : void 0;
70298
- const narrowedType = mapType(candidate, (c) => {
70299
- const discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
70300
- const matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
70301
- const directlyRelated = mapType(
70302
- matching || type,
70303
- checkDerived ? (t) => isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType : (t) => isTypeStrictSubtypeOf(t, c) ? t : isTypeStrictSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : isTypeSubtypeOf(c, t) ? c : neverType
70304
- );
70305
- return directlyRelated.flags & 131072 /* Never */ ? mapType(type, (t) => maybeTypeOfKind(t, 465829888 /* Instantiable */) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType) : directlyRelated;
70306
- });
70848
+ let matchedCandidates = [];
70849
+ let narrowedType = mapType(type, (t) => mapType(
70850
+ candidate,
70851
+ (c) => {
70852
+ if (keyPropertyName) {
70853
+ const discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
70854
+ if (!discriminant || getConstituentTypeForKeyType(type, discriminant) !== t) {
70855
+ return neverType;
70856
+ }
70857
+ }
70858
+ const directlyRelated = checkDerived ? isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType : isTypeStrictSubtypeOf(t, c) ? t : isTypeStrictSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : isTypeSubtypeOf(c, t) ? c : neverType;
70859
+ if (!(directlyRelated.flags & 131072 /* Never */)) {
70860
+ matchedCandidates = appendIfUnique(matchedCandidates, c);
70861
+ }
70862
+ return directlyRelated;
70863
+ }
70864
+ ));
70865
+ if (matchedCandidates.length !== countTypes(candidate)) {
70866
+ narrowedType = getUnionType([
70867
+ narrowedType,
70868
+ mapType(candidate, (c) => {
70869
+ return !containsType(matchedCandidates, c) ? mapType(type, (t) => maybeTypeOfKind(t, 465829888 /* Instantiable */) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType) : neverType;
70870
+ })
70871
+ ]);
70872
+ }
70307
70873
  return !(narrowedType.flags & 131072 /* Never */) ? narrowedType : isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]);
70308
70874
  }
70309
70875
  function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
@@ -74854,11 +75420,11 @@ function createTypeChecker(host) {
74854
75420
  const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
74855
75421
  const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
74856
75422
  applyToParameterTypes(sourceSignature, signature, (source, target) => {
74857
- inferTypes(context, context.inferences, source, target);
75423
+ inferTypes(context.inferences, source, target);
74858
75424
  });
74859
75425
  if (!inferenceContext) {
74860
75426
  applyToReturnTypes(contextualSignature, signature, (source, target) => {
74861
- inferTypes(context, context.inferences, source, target, 128 /* ReturnType */);
75427
+ inferTypes(context.inferences, source, target, 128 /* ReturnType */);
74862
75428
  });
74863
75429
  }
74864
75430
  return getSignatureInstantiation(signature, getInferredTypes(context), isInJSFile(contextualSignature.declaration));
@@ -74866,7 +75432,7 @@ function createTypeChecker(host) {
74866
75432
  function inferJsxTypeArguments(node, signature, checkMode, context) {
74867
75433
  const paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
74868
75434
  const checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
74869
- inferTypes(context, context.inferences, checkAttrType, paramType);
75435
+ inferTypes(context.inferences, checkAttrType, paramType);
74870
75436
  return getInferredTypes(context);
74871
75437
  }
74872
75438
  function getThisArgumentType(thisArgumentNode) {
@@ -74893,11 +75459,11 @@ function createTypeChecker(host) {
74893
75459
  const instantiatedType = instantiateType(contextualType, outerMapper);
74894
75460
  const contextualSignature = getSingleCallSignature(instantiatedType);
74895
75461
  const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType;
74896
- inferTypes(context, context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
75462
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
74897
75463
  }
74898
75464
  const returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
74899
75465
  const returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
74900
- inferTypes(returnContext, returnContext.inferences, returnSourceType, inferenceTargetType);
75466
+ inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
74901
75467
  context.returnMapper = some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : void 0;
74902
75468
  }
74903
75469
  }
@@ -74913,7 +75479,7 @@ function createTypeChecker(host) {
74913
75479
  const thisType = getThisTypeOfSignature(signature);
74914
75480
  if (thisType && couldContainTypeVariables(thisType)) {
74915
75481
  const thisArgumentNode = getThisArgumentOfCall(node);
74916
- inferTypes(context, context.inferences, getThisArgumentType(thisArgumentNode), thisType);
75482
+ inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
74917
75483
  }
74918
75484
  for (let i = 0; i < argCount; i++) {
74919
75485
  const arg = args[i];
@@ -74921,13 +75487,13 @@ function createTypeChecker(host) {
74921
75487
  const paramType = getTypeAtPosition(signature, i);
74922
75488
  if (couldContainTypeVariables(paramType)) {
74923
75489
  const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
74924
- inferTypes(context, context.inferences, argType, paramType);
75490
+ inferTypes(context.inferences, argType, paramType);
74925
75491
  }
74926
75492
  }
74927
75493
  }
74928
75494
  if (restType && couldContainTypeVariables(restType)) {
74929
75495
  const spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
74930
- inferTypes(context, context.inferences, spreadType, restType);
75496
+ inferTypes(context.inferences, spreadType, restType);
74931
75497
  }
74932
75498
  return getInferredTypes(context);
74933
75499
  }
@@ -77300,14 +77866,14 @@ function createTypeChecker(host) {
77300
77866
  isOptionalDeclaration(declaration)
77301
77867
  );
77302
77868
  const target = getTypeAtPosition(context, i);
77303
- inferTypes(inferenceContext, inferenceContext.inferences, source, target);
77869
+ inferTypes(inferenceContext.inferences, source, target);
77304
77870
  }
77305
77871
  }
77306
77872
  const typeNode = signature.declaration && getEffectiveReturnTypeNode(signature.declaration);
77307
77873
  if (typeNode) {
77308
77874
  const source = getTypeFromTypeNode(typeNode);
77309
77875
  const target = getReturnTypeOfSignature(context);
77310
- inferTypes(inferenceContext, inferenceContext.inferences, source, target);
77876
+ inferTypes(inferenceContext.inferences, source, target);
77311
77877
  }
77312
77878
  }
77313
77879
  function assignContextualParameterTypes(signature, context) {
@@ -79723,7 +80289,6 @@ function createTypeChecker(host) {
79723
80289
  const inferences = map(context.inferences, (info) => createInferenceInfo(info.typeParameter));
79724
80290
  applyToParameterTypes(instantiatedSignature, contextualSignature, (source, target) => {
79725
80291
  inferTypes(
79726
- context,
79727
80292
  inferences,
79728
80293
  source,
79729
80294
  target,
@@ -79735,7 +80300,7 @@ function createTypeChecker(host) {
79735
80300
  });
79736
80301
  if (some(inferences, hasInferenceCandidates)) {
79737
80302
  applyToReturnTypes(instantiatedSignature, contextualSignature, (source, target) => {
79738
- inferTypes(context, inferences, source, target);
80303
+ inferTypes(inferences, source, target);
79739
80304
  });
79740
80305
  if (!hasOverlappingInferences(context.inferences, inferences)) {
79741
80306
  mergeInferences(context.inferences, inferences);
@@ -87463,6 +88028,9 @@ function createTypeChecker(host) {
87463
88028
  tracker.trackSymbol(name, enclosing, 111551 /* Value */);
87464
88029
  }
87465
88030
  }
88031
+ },
88032
+ symbolToDeclarations: (symbol, meaning, flags, verbosityLevel, out) => {
88033
+ return nodeBuilder.symbolToDeclarations(symbol, meaning, flags, verbosityLevel, out);
87466
88034
  }
87467
88035
  };
87468
88036
  function isImportRequiredByAugmentation(node) {
@@ -115366,7 +115934,8 @@ var notImplementedResolver = {
115366
115934
  getDeclarationStatementsForSourceFile: notImplemented,
115367
115935
  isImportRequiredByAugmentation: notImplemented,
115368
115936
  isDefinitelyReferenceToGlobalSymbolObject: notImplemented,
115369
- createLateBoundIndexSignatures: notImplemented
115937
+ createLateBoundIndexSignatures: notImplemented,
115938
+ symbolToDeclarations: notImplemented
115370
115939
  };
115371
115940
  var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
115372
115941
  var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));