typescript 5.5.0-dev.20240506 → 5.5.0-dev.20240507

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.
Files changed (3) hide show
  1. package/lib/tsc.js +265 -155
  2. package/lib/typescript.js +267 -157
  3. package/package.json +2 -2
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.5";
21
- var version = `${versionMajorMinor}.0-dev.20240506`;
21
+ var version = `${versionMajorMinor}.0-dev.20240507`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -62471,7 +62471,7 @@ function createTypeChecker(host) {
62471
62471
  for (let i = 0; i < paramCount; i++) {
62472
62472
  const sourceType = i === restIndex ? getRestOrAnyTypeAtPosition(source, i) : tryGetTypeAtPosition(source, i);
62473
62473
  const targetType = i === restIndex ? getRestOrAnyTypeAtPosition(target, i) : tryGetTypeAtPosition(target, i);
62474
- if (sourceType && targetType) {
62474
+ if (sourceType && targetType && (sourceType !== targetType || checkMode & 8 /* StrictArity */)) {
62475
62475
  const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
62476
62476
  const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
62477
62477
  const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
@@ -114211,13 +114211,9 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114211
114211
  }
114212
114212
  }
114213
114213
  function emitComputedPropertyName(node) {
114214
- const savedPrivateNameTempFlags = privateNameTempFlags;
114215
- const savedReservedMemberNames = reservedPrivateNames;
114216
- popPrivateNameGenerationScope();
114217
114214
  writePunctuation("[");
114218
114215
  emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfComputedPropertyName);
114219
114216
  writePunctuation("]");
114220
- pushPrivateNameGenerationScope(savedPrivateNameTempFlags, savedReservedMemberNames);
114221
114217
  }
114222
114218
  function emitTypeParameter(node) {
114223
114219
  emitModifierList(node, node.modifiers);
@@ -114278,15 +114274,10 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114278
114274
  writeTrailingSemicolon();
114279
114275
  }
114280
114276
  function emitMethodSignature(node) {
114281
- pushNameGenerationScope(node);
114282
114277
  emitModifierList(node, node.modifiers);
114283
114278
  emit(node.name);
114284
114279
  emit(node.questionToken);
114285
- emitTypeParameters(node, node.typeParameters);
114286
- emitParameters(node, node.parameters);
114287
- emitTypeAnnotation(node.type);
114288
- writeTrailingSemicolon();
114289
- popNameGenerationScope(node);
114280
+ emitSignatureAndBody(node, emitSignatureHead, emitEmptyFunctionBody);
114290
114281
  }
114291
114282
  function emitMethodDeclaration(node) {
114292
114283
  emitDecoratorsAndModifiers(
@@ -114298,11 +114289,13 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114298
114289
  emit(node.asteriskToken);
114299
114290
  emit(node.name);
114300
114291
  emit(node.questionToken);
114301
- emitSignatureAndBody(node, emitSignatureHead);
114292
+ emitSignatureAndBody(node, emitSignatureHead, emitFunctionBody);
114302
114293
  }
114303
114294
  function emitClassStaticBlockDeclaration(node) {
114304
114295
  writeKeyword("static");
114296
+ pushNameGenerationScope(node);
114305
114297
  emitBlockFunctionBody(node.body);
114298
+ popNameGenerationScope(node);
114306
114299
  }
114307
114300
  function emitConstructor(node) {
114308
114301
  emitDecoratorsAndModifiers(
@@ -114312,7 +114305,7 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114312
114305
  false
114313
114306
  );
114314
114307
  writeKeyword("constructor");
114315
- emitSignatureAndBody(node, emitSignatureHead);
114308
+ emitSignatureAndBody(node, emitSignatureHead, emitFunctionBody);
114316
114309
  }
114317
114310
  function emitAccessorDeclaration(node) {
114318
114311
  const pos = emitDecoratorsAndModifiers(
@@ -114325,25 +114318,15 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114325
114318
  emitTokenWithComment(token, pos, writeKeyword, node);
114326
114319
  writeSpace();
114327
114320
  emit(node.name);
114328
- emitSignatureAndBody(node, emitSignatureHead);
114321
+ emitSignatureAndBody(node, emitSignatureHead, emitFunctionBody);
114329
114322
  }
114330
114323
  function emitCallSignature(node) {
114331
- pushNameGenerationScope(node);
114332
- emitTypeParameters(node, node.typeParameters);
114333
- emitParameters(node, node.parameters);
114334
- emitTypeAnnotation(node.type);
114335
- writeTrailingSemicolon();
114336
- popNameGenerationScope(node);
114324
+ emitSignatureAndBody(node, emitSignatureHead, emitEmptyFunctionBody);
114337
114325
  }
114338
114326
  function emitConstructSignature(node) {
114339
- pushNameGenerationScope(node);
114340
114327
  writeKeyword("new");
114341
114328
  writeSpace();
114342
- emitTypeParameters(node, node.typeParameters);
114343
- emitParameters(node, node.parameters);
114344
- emitTypeAnnotation(node.type);
114345
- writeTrailingSemicolon();
114346
- popNameGenerationScope(node);
114329
+ emitSignatureAndBody(node, emitSignatureHead, emitEmptyFunctionBody);
114347
114330
  }
114348
114331
  function emitIndexSignature(node) {
114349
114332
  emitDecoratorsAndModifiers(
@@ -114381,14 +114364,17 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114381
114364
  emitTypeArguments(node, node.typeArguments);
114382
114365
  }
114383
114366
  function emitFunctionType(node) {
114384
- pushNameGenerationScope(node);
114367
+ emitSignatureAndBody(node, emitFunctionTypeHead, emitFunctionTypeBody);
114368
+ }
114369
+ function emitFunctionTypeHead(node) {
114385
114370
  emitTypeParameters(node, node.typeParameters);
114386
114371
  emitParametersForArrow(node, node.parameters);
114387
114372
  writeSpace();
114388
114373
  writePunctuation("=>");
114374
+ }
114375
+ function emitFunctionTypeBody(node) {
114389
114376
  writeSpace();
114390
114377
  emit(node.type);
114391
- popNameGenerationScope(node);
114392
114378
  }
114393
114379
  function emitJSDocFunctionType(node) {
114394
114380
  writeKeyword("function");
@@ -114409,17 +114395,10 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114409
114395
  writePunctuation("=");
114410
114396
  }
114411
114397
  function emitConstructorType(node) {
114412
- pushNameGenerationScope(node);
114413
114398
  emitModifierList(node, node.modifiers);
114414
114399
  writeKeyword("new");
114415
114400
  writeSpace();
114416
- emitTypeParameters(node, node.typeParameters);
114417
- emitParameters(node, node.parameters);
114418
- writeSpace();
114419
- writePunctuation("=>");
114420
- writeSpace();
114421
- emit(node.type);
114422
- popNameGenerationScope(node);
114401
+ emitSignatureAndBody(node, emitFunctionTypeHead, emitFunctionTypeBody);
114423
114402
  }
114424
114403
  function emitTypeQuery(node) {
114425
114404
  writeKeyword("typeof");
@@ -114428,16 +114407,13 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114428
114407
  emitTypeArguments(node, node.typeArguments);
114429
114408
  }
114430
114409
  function emitTypeLiteral(node) {
114431
- pushPrivateNameGenerationScope(
114432
- 0 /* Auto */,
114433
- /*newReservedMemberNames*/
114434
- void 0
114435
- );
114410
+ pushNameGenerationScope(node);
114411
+ forEach(node.members, generateMemberNames);
114436
114412
  writePunctuation("{");
114437
114413
  const flags = getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */;
114438
114414
  emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */);
114439
114415
  writePunctuation("}");
114440
- popPrivateNameGenerationScope();
114416
+ popNameGenerationScope(node);
114441
114417
  }
114442
114418
  function emitArrayType(node) {
114443
114419
  emit(node.elementType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
@@ -114609,11 +114585,7 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114609
114585
  emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma);
114610
114586
  }
114611
114587
  function emitObjectLiteralExpression(node) {
114612
- pushPrivateNameGenerationScope(
114613
- 0 /* Auto */,
114614
- /*newReservedMemberNames*/
114615
- void 0
114616
- );
114588
+ pushNameGenerationScope(node);
114617
114589
  forEach(node.properties, generateMemberNames);
114618
114590
  const indentedFlag = getEmitFlags(node) & 131072 /* Indented */;
114619
114591
  if (indentedFlag) {
@@ -114625,7 +114597,7 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114625
114597
  if (indentedFlag) {
114626
114598
  decreaseIndent();
114627
114599
  }
114628
- popPrivateNameGenerationScope();
114600
+ popNameGenerationScope(node);
114629
114601
  }
114630
114602
  function emitPropertyAccessExpression(node) {
114631
114603
  emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess);
@@ -114740,7 +114712,7 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114740
114712
  }
114741
114713
  function emitArrowFunction(node) {
114742
114714
  emitModifierList(node, node.modifiers);
114743
- emitSignatureAndBody(node, emitArrowFunctionHead);
114715
+ emitSignatureAndBody(node, emitArrowFunctionHead, emitArrowFunctionBody);
114744
114716
  }
114745
114717
  function emitArrowFunctionHead(node) {
114746
114718
  emitTypeParameters(node, node.typeParameters);
@@ -114749,6 +114721,14 @@ function createPrinter(printerOptions = {}, handlers = {}) {
114749
114721
  writeSpace();
114750
114722
  emit(node.equalsGreaterThanToken);
114751
114723
  }
114724
+ function emitArrowFunctionBody(node) {
114725
+ if (isBlock(node.body)) {
114726
+ emitBlockFunctionBody(node.body);
114727
+ } else {
114728
+ writeSpace();
114729
+ emitExpression(node.body, parenthesizer.parenthesizeConciseBodyOfArrowFunction);
114730
+ }
114731
+ }
114752
114732
  function emitDeleteExpression(node) {
114753
114733
  emitTokenWithComment(91 /* DeleteKeyword */, node.pos, writeKeyword, node);
114754
114734
  writeSpace();
@@ -115296,35 +115276,33 @@ function createPrinter(printerOptions = {}, handlers = {}) {
115296
115276
  emit(node.asteriskToken);
115297
115277
  writeSpace();
115298
115278
  emitIdentifierName(node.name);
115299
- emitSignatureAndBody(node, emitSignatureHead);
115279
+ emitSignatureAndBody(node, emitSignatureHead, emitFunctionBody);
115300
115280
  }
115301
- function emitSignatureAndBody(node, emitSignatureHead2) {
115281
+ function emitSignatureAndBody(node, emitSignatureHead2, emitBody) {
115282
+ const indentedFlag = getEmitFlags(node) & 131072 /* Indented */;
115283
+ if (indentedFlag) {
115284
+ increaseIndent();
115285
+ }
115286
+ pushNameGenerationScope(node);
115287
+ forEach(node.parameters, generateNames);
115288
+ emitSignatureHead2(node);
115289
+ emitBody(node);
115290
+ popNameGenerationScope(node);
115291
+ if (indentedFlag) {
115292
+ decreaseIndent();
115293
+ }
115294
+ }
115295
+ function emitFunctionBody(node) {
115302
115296
  const body = node.body;
115303
115297
  if (body) {
115304
- if (isBlock(body)) {
115305
- const indentedFlag = getEmitFlags(node) & 131072 /* Indented */;
115306
- if (indentedFlag) {
115307
- increaseIndent();
115308
- }
115309
- pushNameGenerationScope(node);
115310
- forEach(node.parameters, generateNames);
115311
- generateNames(node.body);
115312
- emitSignatureHead2(node);
115313
- emitBlockFunctionBody(body);
115314
- popNameGenerationScope(node);
115315
- if (indentedFlag) {
115316
- decreaseIndent();
115317
- }
115318
- } else {
115319
- emitSignatureHead2(node);
115320
- writeSpace();
115321
- emitExpression(body, parenthesizer.parenthesizeConciseBodyOfArrowFunction);
115322
- }
115298
+ emitBlockFunctionBody(body);
115323
115299
  } else {
115324
- emitSignatureHead2(node);
115325
115300
  writeTrailingSemicolon();
115326
115301
  }
115327
115302
  }
115303
+ function emitEmptyFunctionBody(_node) {
115304
+ writeTrailingSemicolon();
115305
+ }
115328
115306
  function emitSignatureHead(node) {
115329
115307
  emitTypeParameters(node, node.typeParameters);
115330
115308
  emitParameters(node, node.parameters);
@@ -115353,6 +115331,7 @@ function createPrinter(printerOptions = {}, handlers = {}) {
115353
115331
  return true;
115354
115332
  }
115355
115333
  function emitBlockFunctionBody(body) {
115334
+ generateNames(body);
115356
115335
  onBeforeEmitNode == null ? void 0 : onBeforeEmitNode(body);
115357
115336
  writeSpace();
115358
115337
  writePunctuation("{");
@@ -115393,12 +115372,6 @@ function createPrinter(printerOptions = {}, handlers = {}) {
115393
115372
  emitClassDeclarationOrExpression(node);
115394
115373
  }
115395
115374
  function emitClassDeclarationOrExpression(node) {
115396
- pushPrivateNameGenerationScope(
115397
- 0 /* Auto */,
115398
- /*newReservedMemberNames*/
115399
- void 0
115400
- );
115401
- forEach(node.members, generateMemberNames);
115402
115375
  emitDecoratorsAndModifiers(
115403
115376
  node,
115404
115377
  node.modifiers,
@@ -115418,19 +115391,16 @@ function createPrinter(printerOptions = {}, handlers = {}) {
115418
115391
  emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */);
115419
115392
  writeSpace();
115420
115393
  writePunctuation("{");
115394
+ pushNameGenerationScope(node);
115395
+ forEach(node.members, generateMemberNames);
115421
115396
  emitList(node, node.members, 129 /* ClassMembers */);
115397
+ popNameGenerationScope(node);
115422
115398
  writePunctuation("}");
115423
115399
  if (indentedFlag) {
115424
115400
  decreaseIndent();
115425
115401
  }
115426
- popPrivateNameGenerationScope();
115427
115402
  }
115428
115403
  function emitInterfaceDeclaration(node) {
115429
- pushPrivateNameGenerationScope(
115430
- 0 /* Auto */,
115431
- /*newReservedMemberNames*/
115432
- void 0
115433
- );
115434
115404
  emitDecoratorsAndModifiers(
115435
115405
  node,
115436
115406
  node.modifiers,
@@ -115444,9 +115414,11 @@ function createPrinter(printerOptions = {}, handlers = {}) {
115444
115414
  emitList(node, node.heritageClauses, 512 /* HeritageClauses */);
115445
115415
  writeSpace();
115446
115416
  writePunctuation("{");
115417
+ pushNameGenerationScope(node);
115418
+ forEach(node.members, generateMemberNames);
115447
115419
  emitList(node, node.members, 129 /* InterfaceMembers */);
115420
+ popNameGenerationScope(node);
115448
115421
  writePunctuation("}");
115449
- popPrivateNameGenerationScope();
115450
115422
  }
115451
115423
  function emitTypeAliasDeclaration(node) {
115452
115424
  emitDecoratorsAndModifiers(
@@ -116827,6 +116799,9 @@ function createPrinter(printerOptions = {}, handlers = {}) {
116827
116799
  return getLiteralText(node, currentSourceFile, flags);
116828
116800
  }
116829
116801
  function pushNameGenerationScope(node) {
116802
+ privateNameTempFlagsStack.push(privateNameTempFlags);
116803
+ privateNameTempFlags = 0 /* Auto */;
116804
+ reservedPrivateNamesStack.push(reservedPrivateNames);
116830
116805
  if (node && getEmitFlags(node) & 1048576 /* ReuseTempVariableScope */) {
116831
116806
  return;
116832
116807
  }
@@ -116837,6 +116812,8 @@ function createPrinter(printerOptions = {}, handlers = {}) {
116837
116812
  reservedNamesStack.push(reservedNames);
116838
116813
  }
116839
116814
  function popNameGenerationScope(node) {
116815
+ privateNameTempFlags = privateNameTempFlagsStack.pop();
116816
+ reservedPrivateNames = reservedPrivateNamesStack.pop();
116840
116817
  if (node && getEmitFlags(node) & 1048576 /* ReuseTempVariableScope */) {
116841
116818
  return;
116842
116819
  }
@@ -116850,16 +116827,6 @@ function createPrinter(printerOptions = {}, handlers = {}) {
116850
116827
  }
116851
116828
  reservedNames.add(name);
116852
116829
  }
116853
- function pushPrivateNameGenerationScope(newPrivateNameTempFlags, newReservedMemberNames) {
116854
- privateNameTempFlagsStack.push(privateNameTempFlags);
116855
- privateNameTempFlags = newPrivateNameTempFlags;
116856
- reservedPrivateNamesStack.push(reservedNames);
116857
- reservedPrivateNames = newReservedMemberNames;
116858
- }
116859
- function popPrivateNameGenerationScope() {
116860
- privateNameTempFlags = privateNameTempFlagsStack.pop();
116861
- reservedPrivateNames = reservedPrivateNamesStack.pop();
116862
- }
116863
116830
  function reservePrivateNameInNestedScopes(name) {
116864
116831
  if (!reservedPrivateNames || reservedPrivateNames === lastOrUndefined(reservedPrivateNamesStack)) {
116865
116832
  reservedPrivateNames = /* @__PURE__ */ new Set();
@@ -116959,7 +116926,9 @@ function createPrinter(printerOptions = {}, handlers = {}) {
116959
116926
  case 303 /* PropertyAssignment */:
116960
116927
  case 304 /* ShorthandPropertyAssignment */:
116961
116928
  case 172 /* PropertyDeclaration */:
116929
+ case 171 /* PropertySignature */:
116962
116930
  case 174 /* MethodDeclaration */:
116931
+ case 173 /* MethodSignature */:
116963
116932
  case 177 /* GetAccessor */:
116964
116933
  case 178 /* SetAccessor */:
116965
116934
  generateNameIfNeeded(node.name);
@@ -116993,7 +116962,28 @@ function createPrinter(printerOptions = {}, handlers = {}) {
116993
116962
  return isFileLevelUniqueNameInCurrentFile(name, privateName) && !isReservedName(name, privateName) && !generatedNames.has(name);
116994
116963
  }
116995
116964
  function isReservedName(name, privateName) {
116996
- return privateName ? !!(reservedPrivateNames == null ? void 0 : reservedPrivateNames.has(name)) : !!(reservedNames == null ? void 0 : reservedNames.has(name));
116965
+ let set;
116966
+ let stack;
116967
+ if (privateName) {
116968
+ set = reservedPrivateNames;
116969
+ stack = reservedPrivateNamesStack;
116970
+ } else {
116971
+ set = reservedNames;
116972
+ stack = reservedNamesStack;
116973
+ }
116974
+ if (set == null ? void 0 : set.has(name)) {
116975
+ return true;
116976
+ }
116977
+ for (let i = stack.length - 1; i >= 0; i--) {
116978
+ if (set === stack[i]) {
116979
+ continue;
116980
+ }
116981
+ set = stack[i];
116982
+ if (set == null ? void 0 : set.has(name)) {
116983
+ return true;
116984
+ }
116985
+ }
116986
+ return false;
116997
116987
  }
116998
116988
  function isFileLevelUniqueNameInCurrentFile(name, _isPrivate) {
116999
116989
  return currentSourceFile ? isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) : true;
@@ -118796,10 +118786,12 @@ function getLibraryNameFromLibFileName(libFileName) {
118796
118786
  }
118797
118787
  return "@typescript/lib-" + path;
118798
118788
  }
118789
+ function getLibNameFromLibReference(libReference) {
118790
+ return toFileNameLowerCase(libReference.fileName);
118791
+ }
118799
118792
  function getLibFileNameFromLibReference(libReference) {
118800
- const libName = toFileNameLowerCase(libReference.fileName);
118801
- const libFileName = libMap.get(libName);
118802
- return { libName, libFileName };
118793
+ const libName = getLibNameFromLibReference(libReference);
118794
+ return libMap.get(libName);
118803
118795
  }
118804
118796
  function isReferencedFile(reason) {
118805
118797
  switch (reason == null ? void 0 : reason.kind) {
@@ -119042,6 +119034,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119042
119034
  let classifiableNames;
119043
119035
  const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
119044
119036
  let fileReasons = createMultiMap();
119037
+ let filesWithReferencesProcessed;
119038
+ let fileReasonsToChain;
119039
+ let reasonToRelatedInfo;
119045
119040
  const cachedBindAndCheckDiagnosticsForFile = {};
119046
119041
  const cachedDeclarationDiagnosticsForFile = {};
119047
119042
  let resolvedTypeReferenceDirectives = createModeAwareCache();
@@ -119073,6 +119068,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119073
119068
  const getDefaultLibraryFileName = memoize(() => host.getDefaultLibFileName(options));
119074
119069
  const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(getDefaultLibraryFileName());
119075
119070
  const programDiagnostics = createDiagnosticCollection();
119071
+ let lazyProgramDiagnosticExplainingFile = [];
119076
119072
  const currentDirectory = host.getCurrentDirectory();
119077
119073
  const supportedExtensions = getSupportedExtensions(options);
119078
119074
  const supportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
@@ -119279,6 +119275,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119279
119275
  files = stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
119280
119276
  processingDefaultLibFiles = void 0;
119281
119277
  processingOtherFiles = void 0;
119278
+ filesWithReferencesProcessed = void 0;
119282
119279
  }
119283
119280
  if (oldProgram && host.onReleaseOldSourceFile) {
119284
119281
  const oldSourceFiles = oldProgram.getSourceFiles();
@@ -119401,24 +119398,64 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119401
119398
  writeFile: writeFile2
119402
119399
  };
119403
119400
  onProgramCreateComplete();
119404
- fileProcessingDiagnostics == null ? void 0 : fileProcessingDiagnostics.forEach((diagnostic) => {
119405
- switch (diagnostic.kind) {
119406
- case 1 /* FilePreprocessingFileExplainingDiagnostic */:
119407
- return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || emptyArray));
119408
- case 0 /* FilePreprocessingReferencedDiagnostic */:
119409
- const { file, pos, end } = getReferencedFileLocation(program, diagnostic.reason);
119410
- return programDiagnostics.add(createFileDiagnostic(file, Debug.checkDefined(pos), Debug.checkDefined(end) - pos, diagnostic.diagnostic, ...diagnostic.args || emptyArray));
119411
- case 2 /* ResolutionDiagnostics */:
119412
- return diagnostic.diagnostics.forEach((d) => programDiagnostics.add(d));
119413
- default:
119414
- Debug.assertNever(diagnostic);
119415
- }
119416
- });
119417
119401
  verifyCompilerOptions();
119418
119402
  mark("afterProgram");
119419
119403
  measure("Program", "beforeProgram", "afterProgram");
119420
119404
  (_p = tracing) == null ? void 0 : _p.pop();
119421
119405
  return program;
119406
+ function updateAndGetProgramDiagnostics() {
119407
+ if (lazyProgramDiagnosticExplainingFile) {
119408
+ fileProcessingDiagnostics == null ? void 0 : fileProcessingDiagnostics.forEach((diagnostic) => {
119409
+ switch (diagnostic.kind) {
119410
+ case 1 /* FilePreprocessingFileExplainingDiagnostic */:
119411
+ return programDiagnostics.add(
119412
+ createDiagnosticExplainingFile(
119413
+ diagnostic.file && getSourceFileByPath(diagnostic.file),
119414
+ diagnostic.fileProcessingReason,
119415
+ diagnostic.diagnostic,
119416
+ diagnostic.args || emptyArray
119417
+ )
119418
+ );
119419
+ case 0 /* FilePreprocessingLibReferenceDiagnostic */:
119420
+ return programDiagnostics.add(filePreprocessingLibreferenceDiagnostic(diagnostic));
119421
+ case 2 /* ResolutionDiagnostics */:
119422
+ return diagnostic.diagnostics.forEach((d) => programDiagnostics.add(d));
119423
+ default:
119424
+ Debug.assertNever(diagnostic);
119425
+ }
119426
+ });
119427
+ lazyProgramDiagnosticExplainingFile.forEach(
119428
+ ({ file, diagnostic, args }) => programDiagnostics.add(
119429
+ createDiagnosticExplainingFile(
119430
+ file,
119431
+ /*fileProcessingReason*/
119432
+ void 0,
119433
+ diagnostic,
119434
+ args
119435
+ )
119436
+ )
119437
+ );
119438
+ lazyProgramDiagnosticExplainingFile = void 0;
119439
+ fileReasonsToChain = void 0;
119440
+ reasonToRelatedInfo = void 0;
119441
+ }
119442
+ return programDiagnostics;
119443
+ }
119444
+ function filePreprocessingLibreferenceDiagnostic({ reason }) {
119445
+ const { file, pos, end } = getReferencedFileLocation(program, reason);
119446
+ const libReference = file.libReferenceDirectives[reason.index];
119447
+ const libName = getLibNameFromLibReference(libReference);
119448
+ const unqualifiedLibName = removeSuffix(removePrefix(libName, "lib."), ".d.ts");
119449
+ const suggestion = getSpellingSuggestion(unqualifiedLibName, libs, identity);
119450
+ return createFileDiagnostic(
119451
+ file,
119452
+ Debug.checkDefined(pos),
119453
+ Debug.checkDefined(end) - pos,
119454
+ suggestion ? Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : Diagnostics.Cannot_find_lib_definition_for_0,
119455
+ libName,
119456
+ suggestion
119457
+ );
119458
+ }
119422
119459
  function getResolvedModule(file, moduleName, mode) {
119423
119460
  var _a2;
119424
119461
  return (_a2 = resolvedModules == null ? void 0 : resolvedModules.get(file.path)) == null ? void 0 : _a2.get(moduleName, mode);
@@ -120111,7 +120148,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120111
120148
  if (skipTypeChecking(sourceFile, options, program)) {
120112
120149
  return emptyArray;
120113
120150
  }
120114
- const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
120151
+ const programDiagnosticsInFile = updateAndGetProgramDiagnostics().getDiagnostics(sourceFile.fileName);
120115
120152
  if (!((_a2 = sourceFile.commentDirectives) == null ? void 0 : _a2.length)) {
120116
120153
  return programDiagnosticsInFile;
120117
120154
  }
@@ -120458,16 +120495,16 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120458
120495
  }
120459
120496
  function getOptionsDiagnostics() {
120460
120497
  return sortAndDeduplicateDiagnostics(concatenate(
120461
- programDiagnostics.getGlobalDiagnostics(),
120498
+ updateAndGetProgramDiagnostics().getGlobalDiagnostics(),
120462
120499
  getOptionsDiagnosticsOfConfigFile()
120463
120500
  ));
120464
120501
  }
120465
120502
  function getOptionsDiagnosticsOfConfigFile() {
120466
120503
  if (!options.configFile)
120467
120504
  return emptyArray;
120468
- let diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName);
120505
+ let diagnostics = updateAndGetProgramDiagnostics().getDiagnostics(options.configFile.fileName);
120469
120506
  forEachResolvedProjectReference2((resolvedRef) => {
120470
- diagnostics = concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName));
120507
+ diagnostics = concatenate(diagnostics, updateAndGetProgramDiagnostics().getDiagnostics(resolvedRef.sourceFile.fileName));
120471
120508
  });
120472
120509
  return diagnostics;
120473
120510
  }
@@ -120641,7 +120678,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120641
120678
  }
120642
120679
  function getLibFileFromReference(ref) {
120643
120680
  var _a2;
120644
- const { libFileName } = getLibFileNameFromLibReference(ref);
120681
+ const libFileName = getLibFileNameFromLibReference(ref);
120645
120682
  const actualFileName = libFileName && ((_a2 = resolvedLibReferences == null ? void 0 : resolvedLibReferences.get(libFileName)) == null ? void 0 : _a2.actual);
120646
120683
  return actualFileName !== void 0 ? getSourceFile(actualFileName) : void 0;
120647
120684
  }
@@ -120779,8 +120816,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120779
120816
  const originalFileName = fileName;
120780
120817
  if (filesByName.has(path)) {
120781
120818
  const file2 = filesByName.get(path);
120782
- addFileIncludeReason(file2 || void 0, reason);
120783
- if (file2 && !(options.forceConsistentCasingInFileNames === false)) {
120819
+ const addedReason = addFileIncludeReason(
120820
+ file2 || void 0,
120821
+ reason,
120822
+ /*checkExisting*/
120823
+ true
120824
+ );
120825
+ if (file2 && addedReason && !(options.forceConsistentCasingInFileNames === false)) {
120784
120826
  const checkedName = file2.fileName;
120785
120827
  const isRedirect = toPath3(checkedName) !== toPath3(fileName);
120786
120828
  if (isRedirect) {
@@ -120843,7 +120885,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120843
120885
  const dupFile = createRedirectedSourceFile(fileFromPackageId, file, fileName, path, toPath3(fileName), originalFileName, sourceFileOptions);
120844
120886
  redirectTargetsMap.add(fileFromPackageId.path, fileName);
120845
120887
  addFileToFilesByName(dupFile, path, fileName, redirectedPath);
120846
- addFileIncludeReason(dupFile, reason);
120888
+ addFileIncludeReason(
120889
+ dupFile,
120890
+ reason,
120891
+ /*checkExisting*/
120892
+ false
120893
+ );
120847
120894
  sourceFileToPackageName.set(path, packageIdToPackageName(packageId));
120848
120895
  processingOtherFiles.push(dupFile);
120849
120896
  return dupFile;
@@ -120861,7 +120908,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120861
120908
  file.originalFileName = originalFileName;
120862
120909
  file.packageJsonLocations = ((_a2 = sourceFileOptions.packageJsonLocations) == null ? void 0 : _a2.length) ? sourceFileOptions.packageJsonLocations : void 0;
120863
120910
  file.packageJsonScope = sourceFileOptions.packageJsonScope;
120864
- addFileIncludeReason(file, reason);
120911
+ addFileIncludeReason(
120912
+ file,
120913
+ reason,
120914
+ /*checkExisting*/
120915
+ false
120916
+ );
120865
120917
  if (host.useCaseSensitiveFileNames()) {
120866
120918
  const pathLowerCase = toFileNameLowerCase(path);
120867
120919
  const existingFile = filesByNameIgnoreCase.get(pathLowerCase);
@@ -120885,12 +120937,16 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120885
120937
  } else {
120886
120938
  processingOtherFiles.push(file);
120887
120939
  }
120940
+ (filesWithReferencesProcessed ?? (filesWithReferencesProcessed = /* @__PURE__ */ new Set())).add(file.path);
120888
120941
  }
120889
120942
  return file;
120890
120943
  }
120891
- function addFileIncludeReason(file, reason) {
120892
- if (file)
120944
+ function addFileIncludeReason(file, reason, checkExisting) {
120945
+ if (file && (!checkExisting || !isReferencedFile(reason) || !(filesWithReferencesProcessed == null ? void 0 : filesWithReferencesProcessed.has(reason.file)))) {
120893
120946
  fileReasons.add(file.path, reason);
120947
+ return true;
120948
+ }
120949
+ return false;
120894
120950
  }
120895
120951
  function addFileToFilesByName(file, path, fileName, redirectedPath) {
120896
120952
  if (redirectedPath) {
@@ -121120,7 +121176,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121120
121176
  }
121121
121177
  function processLibReferenceDirectives(file) {
121122
121178
  forEach(file.libReferenceDirectives, (libReference, index) => {
121123
- const { libName, libFileName } = getLibFileNameFromLibReference(libReference);
121179
+ const libFileName = getLibFileNameFromLibReference(libReference);
121124
121180
  if (libFileName) {
121125
121181
  processRootFile(
121126
121182
  pathForLibFile(libFileName),
@@ -121131,15 +121187,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121131
121187
  { kind: 7 /* LibReferenceDirective */, file: file.path, index }
121132
121188
  );
121133
121189
  } else {
121134
- const unqualifiedLibName = removeSuffix(removePrefix(libName, "lib."), ".d.ts");
121135
- const suggestion = getSpellingSuggestion(unqualifiedLibName, libs, identity);
121136
- const diagnostic = suggestion ? Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : Diagnostics.Cannot_find_lib_definition_for_0;
121137
- const args = suggestion ? [libName, suggestion] : [libName];
121138
121190
  (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
121139
- kind: 0 /* FilePreprocessingReferencedDiagnostic */,
121140
- reason: { kind: 7 /* LibReferenceDirective */, file: file.path, index },
121141
- diagnostic,
121142
- args
121191
+ kind: 0 /* FilePreprocessingLibReferenceDiagnostic */,
121192
+ reason: { kind: 7 /* LibReferenceDirective */, file: file.path, index }
121143
121193
  });
121144
121194
  }
121145
121195
  });
@@ -121200,7 +121250,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121200
121250
  if (!sourceFile.isDeclarationFile) {
121201
121251
  const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
121202
121252
  if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
121203
- addProgramDiagnosticExplainingFile(
121253
+ addLazyProgramDiagnosticExplainingFile(
121204
121254
  sourceFile,
121205
121255
  Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files,
121206
121256
  [sourceFile.fileName, rootDirectory]
@@ -121330,7 +121380,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121330
121380
  const rootPaths = new Set(rootNames.map(toPath3));
121331
121381
  for (const file of files) {
121332
121382
  if (sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
121333
- addProgramDiagnosticExplainingFile(
121383
+ addLazyProgramDiagnosticExplainingFile(
121334
121384
  file,
121335
121385
  Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern,
121336
121386
  [file.fileName, options.configFilePath || ""]
@@ -121693,31 +121743,90 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121693
121743
  });
121694
121744
  }
121695
121745
  function createDiagnosticExplainingFile(file, fileProcessingReason, diagnostic, args) {
121696
- var _a2;
121746
+ let seenReasons;
121747
+ const reasons = file && fileReasons.get(file.path);
121697
121748
  let fileIncludeReasons;
121698
121749
  let relatedInfo;
121699
121750
  let locationReason = isReferencedFile(fileProcessingReason) ? fileProcessingReason : void 0;
121700
- if (file)
121701
- (_a2 = fileReasons.get(file.path)) == null ? void 0 : _a2.forEach(processReason);
121751
+ let fileIncludeReasonDetails;
121752
+ let redirectInfo;
121753
+ let cachedChain = file && (fileReasonsToChain == null ? void 0 : fileReasonsToChain.get(file.path));
121754
+ let chain;
121755
+ if (cachedChain) {
121756
+ if (cachedChain.fileIncludeReasonDetails) {
121757
+ seenReasons = new Set(reasons);
121758
+ reasons == null ? void 0 : reasons.forEach(populateRelatedInfo);
121759
+ } else {
121760
+ reasons == null ? void 0 : reasons.forEach(processReason);
121761
+ }
121762
+ redirectInfo = cachedChain.redirectInfo;
121763
+ } else {
121764
+ reasons == null ? void 0 : reasons.forEach(processReason);
121765
+ redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, getCompilerOptionsForFile(file));
121766
+ }
121702
121767
  if (fileProcessingReason)
121703
121768
  processReason(fileProcessingReason);
121704
- if (locationReason && (fileIncludeReasons == null ? void 0 : fileIncludeReasons.length) === 1)
121705
- fileIncludeReasons = void 0;
121769
+ const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
121770
+ if (locationReason && (seenReasons == null ? void 0 : seenReasons.size) === 1)
121771
+ seenReasons = void 0;
121772
+ if (seenReasons && cachedChain) {
121773
+ if (cachedChain.details && !processedExtraReason) {
121774
+ chain = chainDiagnosticMessages(cachedChain.details, diagnostic, ...args || emptyArray);
121775
+ } else if (cachedChain.fileIncludeReasonDetails) {
121776
+ if (!processedExtraReason) {
121777
+ if (!cachedFileIncludeDetailsHasProcessedExtraReason()) {
121778
+ fileIncludeReasonDetails = cachedChain.fileIncludeReasonDetails;
121779
+ } else {
121780
+ fileIncludeReasons = cachedChain.fileIncludeReasonDetails.next.slice(0, reasons.length);
121781
+ }
121782
+ } else {
121783
+ if (!cachedFileIncludeDetailsHasProcessedExtraReason()) {
121784
+ fileIncludeReasons = [...cachedChain.fileIncludeReasonDetails.next, fileIncludeReasons[0]];
121785
+ } else {
121786
+ fileIncludeReasons = append(cachedChain.fileIncludeReasonDetails.next.slice(0, reasons.length), fileIncludeReasons[0]);
121787
+ }
121788
+ }
121789
+ }
121790
+ }
121791
+ if (!chain) {
121792
+ if (!fileIncludeReasonDetails)
121793
+ fileIncludeReasonDetails = seenReasons && chainDiagnosticMessages(fileIncludeReasons, Diagnostics.The_file_is_in_the_program_because_Colon);
121794
+ chain = chainDiagnosticMessages(
121795
+ redirectInfo ? fileIncludeReasonDetails ? [fileIncludeReasonDetails, ...redirectInfo] : redirectInfo : fileIncludeReasonDetails,
121796
+ diagnostic,
121797
+ ...args || emptyArray
121798
+ );
121799
+ }
121800
+ if (file) {
121801
+ if (cachedChain) {
121802
+ if (!cachedChain.fileIncludeReasonDetails || !processedExtraReason && fileIncludeReasonDetails) {
121803
+ cachedChain.fileIncludeReasonDetails = fileIncludeReasonDetails;
121804
+ }
121805
+ } else {
121806
+ (fileReasonsToChain ?? (fileReasonsToChain = /* @__PURE__ */ new Map())).set(file.path, cachedChain = { fileIncludeReasonDetails, redirectInfo });
121807
+ }
121808
+ if (!cachedChain.details && !processedExtraReason)
121809
+ cachedChain.details = chain.next;
121810
+ }
121706
121811
  const location = locationReason && getReferencedFileLocation(program, locationReason);
121707
- const fileIncludeReasonDetails = fileIncludeReasons && chainDiagnosticMessages(fileIncludeReasons, Diagnostics.The_file_is_in_the_program_because_Colon);
121708
- const optionsForFile = file && getCompilerOptionsForFile(file) || options;
121709
- const redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, optionsForFile);
121710
- const chain = chainDiagnosticMessages(redirectInfo ? fileIncludeReasonDetails ? [fileIncludeReasonDetails, ...redirectInfo] : redirectInfo : fileIncludeReasonDetails, diagnostic, ...args || emptyArray);
121711
121812
  return location && isReferenceFileLocation(location) ? createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : createCompilerDiagnosticFromMessageChain(chain, relatedInfo);
121712
121813
  function processReason(reason) {
121713
- (fileIncludeReasons || (fileIncludeReasons = [])).push(fileIncludeReasonToDiagnostics(program, reason));
121814
+ if (seenReasons == null ? void 0 : seenReasons.has(reason))
121815
+ return;
121816
+ (seenReasons ?? (seenReasons = /* @__PURE__ */ new Set())).add(reason);
121817
+ (fileIncludeReasons ?? (fileIncludeReasons = [])).push(fileIncludeReasonToDiagnostics(program, reason));
121818
+ populateRelatedInfo(reason);
121819
+ }
121820
+ function populateRelatedInfo(reason) {
121714
121821
  if (!locationReason && isReferencedFile(reason)) {
121715
121822
  locationReason = reason;
121716
121823
  } else if (locationReason !== reason) {
121717
- relatedInfo = append(relatedInfo, fileIncludeReasonToRelatedInformation(reason));
121824
+ relatedInfo = append(relatedInfo, getFileIncludeReasonToRelatedInformation(reason));
121718
121825
  }
121719
- if (reason === fileProcessingReason)
121720
- fileProcessingReason = void 0;
121826
+ }
121827
+ function cachedFileIncludeDetailsHasProcessedExtraReason() {
121828
+ var _a2;
121829
+ return ((_a2 = cachedChain.fileIncludeReasonDetails.next) == null ? void 0 : _a2.length) !== (reasons == null ? void 0 : reasons.length);
121721
121830
  }
121722
121831
  }
121723
121832
  function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
@@ -121729,14 +121838,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121729
121838
  args
121730
121839
  });
121731
121840
  }
121732
- function addProgramDiagnosticExplainingFile(file, diagnostic, args) {
121733
- programDiagnostics.add(createDiagnosticExplainingFile(
121734
- file,
121735
- /*fileProcessingReason*/
121736
- void 0,
121737
- diagnostic,
121738
- args
121739
- ));
121841
+ function addLazyProgramDiagnosticExplainingFile(file, diagnostic, args) {
121842
+ lazyProgramDiagnosticExplainingFile.push({ file, diagnostic, args });
121843
+ }
121844
+ function getFileIncludeReasonToRelatedInformation(reason) {
121845
+ let relatedInfo = reasonToRelatedInfo == null ? void 0 : reasonToRelatedInfo.get(reason);
121846
+ if (relatedInfo === void 0)
121847
+ (reasonToRelatedInfo ?? (reasonToRelatedInfo = /* @__PURE__ */ new Map())).set(reason, relatedInfo = fileIncludeReasonToRelatedInformation(reason) ?? false);
121848
+ return relatedInfo || void 0;
121740
121849
  }
121741
121850
  function fileIncludeReasonToRelatedInformation(reason) {
121742
121851
  if (isReferencedFile(reason)) {
@@ -125971,6 +126080,7 @@ function createWatchProgram(host) {
125971
126080
  });
125972
126081
  parsedConfigs = void 0;
125973
126082
  }
126083
+ builderProgram = void 0;
125974
126084
  }
125975
126085
  function getResolutionCache() {
125976
126086
  return resolutionCache;