@typescript-deploys/pr-build 5.5.0-pr-58440-13 → 5.5.0-pr-58243-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.5";
21
- var version = `${versionMajorMinor}.0-insiders.20240506`;
21
+ var version = `${versionMajorMinor}.0-insiders.20240507`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -45789,14 +45789,14 @@ function createTypeChecker(host) {
45789
45789
  /*reportErrors*/
45790
45790
  false
45791
45791
  ),
45792
- getAsyncIterableType: () => {
45792
+ getAnyAsyncIterableType: () => {
45793
45793
  const type = getGlobalAsyncIterableType(
45794
45794
  /*reportErrors*/
45795
45795
  false
45796
45796
  );
45797
45797
  if (type === emptyGenericType)
45798
45798
  return void 0;
45799
- return type;
45799
+ return createTypeReference(type, [anyType, anyType, anyType]);
45800
45800
  },
45801
45801
  isSymbolAccessible,
45802
45802
  isArrayType,
@@ -46268,7 +46268,6 @@ function createTypeChecker(host) {
46268
46268
  };
46269
46269
  var anyIterationTypes = createIterationTypes(anyType, anyType, anyType);
46270
46270
  var anyIterationTypesExceptNext = createIterationTypes(anyType, anyType, unknownType);
46271
- var defaultIterationTypes = createIterationTypes(neverType, anyType, undefinedType);
46272
46271
  var asyncIterationTypesResolver = {
46273
46272
  iterableCacheKey: "iterationTypesOfAsyncIterable",
46274
46273
  iteratorCacheKey: "iterationTypesOfAsyncIterator",
@@ -50407,7 +50406,37 @@ function createTypeChecker(host) {
50407
50406
  }
50408
50407
  let typeArgumentNodes;
50409
50408
  if (typeArguments.length > 0) {
50410
- const typeParameterCount = (type2.target.typeParameters || emptyArray).length;
50409
+ let typeParameterCount;
50410
+ if (type2.target.typeParameters) {
50411
+ typeParameterCount = Math.min(type2.target.typeParameters.length, typeArguments.length);
50412
+ if (isReferenceToType(type2, getGlobalIterableType(
50413
+ /*reportErrors*/
50414
+ false
50415
+ )) || isReferenceToType(type2, getGlobalIterableIteratorType(
50416
+ /*reportErrors*/
50417
+ false
50418
+ )) || isReferenceToType(type2, getGlobalAsyncIterableType(
50419
+ /*reportErrors*/
50420
+ false
50421
+ )) || isReferenceToType(type2, getGlobalAsyncIterableIteratorType(
50422
+ /*reportErrors*/
50423
+ false
50424
+ ))) {
50425
+ if (!type2.node || !isTypeReferenceNode(type2.node) || !type2.node.typeArguments || type2.node.typeArguments.length < typeParameterCount) {
50426
+ while (typeParameterCount > 0) {
50427
+ const typeArgument = typeArguments[typeParameterCount - 1];
50428
+ const typeParameter = type2.target.typeParameters[typeParameterCount - 1];
50429
+ const defaultType = getDefaultFromTypeParameter(typeParameter);
50430
+ if (!defaultType || !isTypeIdenticalTo(typeArgument, defaultType)) {
50431
+ break;
50432
+ }
50433
+ typeParameterCount--;
50434
+ }
50435
+ }
50436
+ }
50437
+ } else {
50438
+ typeParameterCount = 0;
50439
+ }
50411
50440
  typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
50412
50441
  }
50413
50442
  const flags = context.flags;
@@ -51899,7 +51928,9 @@ function createTypeChecker(host) {
51899
51928
  );
51900
51929
  }
51901
51930
  if (isNamedDeclaration(node) && node.name.kind === 167 /* ComputedPropertyName */ && !isLateBindableName(node.name)) {
51902
- return void 0;
51931
+ if (!(context.flags & 1 /* AllowUnresolvedComputedNames */ && hasDynamicName(node) && isEntityNameExpression(node.name.expression) && checkComputedPropertyName(node.name).flags & 1 /* Any */)) {
51932
+ return void 0;
51933
+ }
51903
51934
  }
51904
51935
  if (isFunctionLike(node) && !node.type || isPropertyDeclaration(node) && !node.type && !node.initializer || isPropertySignature(node) && !node.type && !node.initializer || isParameter(node) && !node.type && !node.initializer) {
51905
51936
  let visited = visitEachChild(
@@ -55464,6 +55495,9 @@ function createTypeChecker(host) {
55464
55495
  links.instantiations = /* @__PURE__ */ new Map();
55465
55496
  links.instantiations.set(getTypeListId(typeParameters), type);
55466
55497
  }
55498
+ if (type === intrinsicMarkerType && symbol.escapedName === "BuiltinIteratorReturn") {
55499
+ type = compilerOptions.noUncheckedIndexedAccess ? undefinedType : anyType;
55500
+ }
55467
55501
  } else {
55468
55502
  type = errorType;
55469
55503
  if (declaration.kind === 340 /* JSDocEnumTag */) {
@@ -56192,13 +56226,8 @@ function createTypeChecker(host) {
56192
56226
  if (left.typeParameters && right.typeParameters) {
56193
56227
  paramMapper = createTypeMapper(right.typeParameters, left.typeParameters);
56194
56228
  }
56195
- let flags = (left.flags | right.flags) & (167 /* PropagatingFlags */ & ~1 /* HasRestParameter */);
56196
56229
  const declaration = left.declaration;
56197
56230
  const params = combineUnionParameters(left, right, paramMapper);
56198
- const lastParam = lastOrUndefined(params);
56199
- if (lastParam && getCheckFlags(lastParam) & 32768 /* RestParameter */) {
56200
- flags |= 1 /* HasRestParameter */;
56201
- }
56202
56231
  const thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter, paramMapper);
56203
56232
  const minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
56204
56233
  const result = createSignature(
@@ -56211,7 +56240,7 @@ function createTypeChecker(host) {
56211
56240
  /*resolvedTypePredicate*/
56212
56241
  void 0,
56213
56242
  minArgCount,
56214
- flags
56243
+ (left.flags | right.flags) & 167 /* PropagatingFlags */
56215
56244
  );
56216
56245
  result.compositeKind = 1048576 /* Union */;
56217
56246
  result.compositeSignatures = concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]);
@@ -58742,7 +58771,7 @@ function createTypeChecker(host) {
58742
58771
  return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType(
58743
58772
  "AsyncIterable",
58744
58773
  /*arity*/
58745
- 1,
58774
+ 3,
58746
58775
  reportErrors2
58747
58776
  )) || emptyGenericType;
58748
58777
  }
@@ -58758,7 +58787,7 @@ function createTypeChecker(host) {
58758
58787
  return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType(
58759
58788
  "AsyncIterableIterator",
58760
58789
  /*arity*/
58761
- 1,
58790
+ 3,
58762
58791
  reportErrors2
58763
58792
  )) || emptyGenericType;
58764
58793
  }
@@ -58774,7 +58803,7 @@ function createTypeChecker(host) {
58774
58803
  return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType(
58775
58804
  "Iterable",
58776
58805
  /*arity*/
58777
- 1,
58806
+ 3,
58778
58807
  reportErrors2
58779
58808
  )) || emptyGenericType;
58780
58809
  }
@@ -58790,7 +58819,7 @@ function createTypeChecker(host) {
58790
58819
  return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType(
58791
58820
  "IterableIterator",
58792
58821
  /*arity*/
58793
- 1,
58822
+ 3,
58794
58823
  reportErrors2
58795
58824
  )) || emptyGenericType;
58796
58825
  }
@@ -58972,7 +59001,7 @@ function createTypeChecker(host) {
58972
59001
  return createTypeFromGenericGlobalType(getGlobalIterableType(
58973
59002
  /*reportErrors*/
58974
59003
  true
58975
- ), [iteratedType]);
59004
+ ), [iteratedType, voidType, undefinedType]);
58976
59005
  }
58977
59006
  function createArrayType(elementType, readonly) {
58978
59007
  return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]);
@@ -62476,7 +62505,7 @@ function createTypeChecker(host) {
62476
62505
  for (let i = 0; i < paramCount; i++) {
62477
62506
  const sourceType = i === restIndex ? getRestOrAnyTypeAtPosition(source, i) : tryGetTypeAtPosition(source, i);
62478
62507
  const targetType = i === restIndex ? getRestOrAnyTypeAtPosition(target, i) : tryGetTypeAtPosition(target, i);
62479
- if (sourceType && targetType) {
62508
+ if (sourceType && targetType && (sourceType !== targetType || checkMode & 8 /* StrictArity */)) {
62480
62509
  const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
62481
62510
  const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
62482
62511
  const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
@@ -71182,14 +71211,13 @@ function createTypeChecker(host) {
71182
71211
  const paramName = leftName === rightName ? leftName : !leftName ? rightName : !rightName ? leftName : void 0;
71183
71212
  const paramSymbol = createSymbol(
71184
71213
  1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0),
71185
- paramName || `arg${i}`,
71186
- isRestParam ? 32768 /* RestParameter */ : isOptional ? 16384 /* OptionalParameter */ : 0
71214
+ paramName || `arg${i}`
71187
71215
  );
71188
71216
  paramSymbol.links.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
71189
71217
  params[i] = paramSymbol;
71190
71218
  }
71191
71219
  if (needsExtraRestElement) {
71192
- const restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args", 32768 /* RestParameter */);
71220
+ const restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args");
71193
71221
  restParamSymbol.links.type = createArrayType(getTypeAtPosition(shorter, longestCount));
71194
71222
  if (shorter === right) {
71195
71223
  restParamSymbol.links.type = instantiateType(restParamSymbol.links.type, mapper);
@@ -71204,13 +71232,8 @@ function createTypeChecker(host) {
71204
71232
  if (left.typeParameters && right.typeParameters) {
71205
71233
  paramMapper = createTypeMapper(right.typeParameters, left.typeParameters);
71206
71234
  }
71207
- let flags = (left.flags | right.flags) & (167 /* PropagatingFlags */ & ~1 /* HasRestParameter */);
71208
71235
  const declaration = left.declaration;
71209
71236
  const params = combineIntersectionParameters(left, right, paramMapper);
71210
- const lastParam = lastOrUndefined(params);
71211
- if (lastParam && getCheckFlags(lastParam) & 32768 /* RestParameter */) {
71212
- flags |= 1 /* HasRestParameter */;
71213
- }
71214
71237
  const thisParam = combineIntersectionThisParam(left.thisParameter, right.thisParameter, paramMapper);
71215
71238
  const minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
71216
71239
  const result = createSignature(
@@ -71223,7 +71246,7 @@ function createTypeChecker(host) {
71223
71246
  /*resolvedTypePredicate*/
71224
71247
  void 0,
71225
71248
  minArgCount,
71226
- flags
71249
+ (left.flags | right.flags) & 167 /* PropagatingFlags */
71227
71250
  );
71228
71251
  result.compositeKind = 2097152 /* Intersection */;
71229
71252
  result.compositeSignatures = concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]);
@@ -76216,24 +76239,14 @@ function createTypeChecker(host) {
76216
76239
  void 0
76217
76240
  ) || unknownType;
76218
76241
  if (globalGeneratorType === emptyGenericType) {
76219
- const globalType = resolver.getGlobalIterableIteratorType(
76242
+ const globalIterableIteratorType = resolver.getGlobalIterableIteratorType(
76220
76243
  /*reportErrors*/
76221
76244
  false
76222
76245
  );
76223
- const iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : void 0;
76224
- const iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType;
76225
- const iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType;
76226
- if (isTypeAssignableTo(returnType, iterableIteratorReturnType) && isTypeAssignableTo(iterableIteratorNextType, nextType)) {
76227
- if (globalType !== emptyGenericType) {
76228
- return createTypeFromGenericGlobalType(globalType, [yieldType]);
76229
- }
76230
- resolver.getGlobalIterableIteratorType(
76231
- /*reportErrors*/
76232
- true
76233
- );
76234
- return emptyObjectType;
76246
+ if (globalIterableIteratorType !== emptyGenericType) {
76247
+ return createTypeFromGenericGlobalType(globalIterableIteratorType, [yieldType, returnType, nextType]);
76235
76248
  }
76236
- resolver.getGlobalGeneratorType(
76249
+ resolver.getGlobalIterableIteratorType(
76237
76250
  /*reportErrors*/
76238
76251
  true
76239
76252
  );
@@ -81369,41 +81382,14 @@ function createTypeChecker(host) {
81369
81382
  function getIterationTypesOfIterableCached(type, resolver) {
81370
81383
  return getCachedIterationTypes(type, resolver.iterableCacheKey);
81371
81384
  }
81372
- function getIterationTypesOfGlobalIterableType(globalType, resolver) {
81373
- const globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) || getIterationTypesOfIterableSlow(
81374
- globalType,
81375
- resolver,
81376
- /*errorNode*/
81377
- void 0,
81378
- /*errorOutputContainer*/
81379
- void 0,
81380
- /*noCache*/
81381
- false
81382
- );
81383
- return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
81384
- }
81385
81385
  function getIterationTypesOfIterableFast(type, resolver) {
81386
- let globalType;
81387
- if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(
81386
+ if (isReferenceToType(type, resolver.getGlobalIterableType(
81388
81387
  /*reportErrors*/
81389
81388
  false
81390
- )) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(
81389
+ )) || isReferenceToType(type, resolver.getGlobalIterableIteratorType(
81391
81390
  /*reportErrors*/
81392
81391
  false
81393
- ))) {
81394
- const [yieldType] = getTypeArguments(type);
81395
- const { returnType, nextType } = getIterationTypesOfGlobalIterableType(globalType, resolver);
81396
- return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(resolver.resolveIterationType(
81397
- yieldType,
81398
- /*errorNode*/
81399
- void 0
81400
- ) || yieldType, resolver.resolveIterationType(
81401
- returnType,
81402
- /*errorNode*/
81403
- void 0
81404
- ) || returnType, nextType));
81405
- }
81406
- if (isReferenceToType(type, resolver.getGlobalGeneratorType(
81392
+ )) || isReferenceToType(type, resolver.getGlobalGeneratorType(
81407
81393
  /*reportErrors*/
81408
81394
  false
81409
81395
  ))) {
@@ -81448,10 +81434,10 @@ function createTypeChecker(host) {
81448
81434
  !!getAwaitedTypeOfPromise(type) || !allowAsyncIterables && isForOfStatement(errorNode.parent) && errorNode.parent.expression === errorNode && getGlobalAsyncIterableType(
81449
81435
  /*reportErrors*/
81450
81436
  false
81451
- ) !== emptyGenericType && isTypeAssignableTo(type, getGlobalAsyncIterableType(
81437
+ ) !== emptyGenericType && isTypeAssignableTo(type, createTypeFromGenericGlobalType(getGlobalAsyncIterableType(
81452
81438
  /*reportErrors*/
81453
81439
  false
81454
- ))
81440
+ ), [anyType, anyType, anyType]))
81455
81441
  );
81456
81442
  return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
81457
81443
  }
@@ -81481,26 +81467,10 @@ function createTypeChecker(host) {
81481
81467
  return getCachedIterationTypes(type, resolver.iteratorCacheKey);
81482
81468
  }
81483
81469
  function getIterationTypesOfIteratorFast(type, resolver) {
81484
- const globalType = resolver.getGlobalIterableIteratorType(
81470
+ if (isReferenceToType(type, resolver.getGlobalIterableIteratorType(
81485
81471
  /*reportErrors*/
81486
81472
  false
81487
- );
81488
- if (isReferenceToType(type, globalType)) {
81489
- const [yieldType] = getTypeArguments(type);
81490
- const globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || getIterationTypesOfIteratorSlow(
81491
- globalType,
81492
- resolver,
81493
- /*errorNode*/
81494
- void 0,
81495
- /*errorOutputContainer*/
81496
- void 0,
81497
- /*noCache*/
81498
- false
81499
- );
81500
- const { returnType, nextType } = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
81501
- return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
81502
- }
81503
- if (isReferenceToType(type, resolver.getGlobalIteratorType(
81473
+ )) || isReferenceToType(type, resolver.getGlobalIteratorType(
81504
81474
  /*reportErrors*/
81505
81475
  false
81506
81476
  )) || isReferenceToType(type, resolver.getGlobalGeneratorType(
@@ -82724,7 +82694,7 @@ function createTypeChecker(host) {
82724
82694
  checkExportsOnMergedDeclarations(node);
82725
82695
  checkTypeParameters(node.typeParameters);
82726
82696
  if (node.type.kind === 141 /* IntrinsicKeyword */) {
82727
- if (!intrinsicTypeKinds.has(node.name.escapedText) || length(node.typeParameters) !== 1) {
82697
+ if (!(node.name.escapedText === "BuiltinIteratorReturn" && length(node.typeParameters) === 0) && !(intrinsicTypeKinds.has(node.name.escapedText) && length(node.typeParameters) === 1)) {
82728
82698
  error(node.type, Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types);
82729
82699
  }
82730
82700
  } else {
@@ -110656,7 +110626,7 @@ function getDeclarationDiagnostics(host, resolver, file) {
110656
110626
  );
110657
110627
  return result.diagnostics;
110658
110628
  }
110659
- var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */;
110629
+ var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 1 /* AllowUnresolvedComputedNames */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */;
110660
110630
  function transformDeclarations(context) {
110661
110631
  const throwDiagnostic = () => Debug.fail("Diagnostic emitted without context");
110662
110632
  let getSymbolAccessibilityDiagnostic = throwDiagnostic;
@@ -111360,7 +111330,9 @@ function transformDeclarations(context) {
111360
111330
  if (isolatedDeclarations && isClassDeclaration(input.parent) && isEntityNameExpression(input.name.expression) && resolver.isEntityNameVisible(input.name.expression, input.parent).accessibility === 0 /* Accessible */ && !resolver.isNonNarrowedBindableName(input.name)) {
111361
111331
  context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
111362
111332
  }
111363
- return;
111333
+ if (!isEntityNameExpression(input.name.expression)) {
111334
+ return;
111335
+ }
111364
111336
  }
111365
111337
  }
111366
111338
  if (isFunctionLike(input) && resolver.isImplementationOfOverload(input))
@@ -112161,7 +112133,7 @@ function transformDeclarations(context) {
112161
112133
  getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNodeName(node);
112162
112134
  }
112163
112135
  errorNameNode = node.name;
112164
- Debug.assert(resolver.isLateBound(getParseTreeNode(node)));
112136
+ Debug.assert(hasDynamicName(node));
112165
112137
  const decl = node;
112166
112138
  const entityName = decl.name.expression;
112167
112139
  checkEntityNameVisibility(entityName, enclosingDeclaration);
@@ -118797,10 +118769,12 @@ function getLibraryNameFromLibFileName(libFileName) {
118797
118769
  }
118798
118770
  return "@typescript/lib-" + path;
118799
118771
  }
118772
+ function getLibNameFromLibReference(libReference) {
118773
+ return toFileNameLowerCase(libReference.fileName);
118774
+ }
118800
118775
  function getLibFileNameFromLibReference(libReference) {
118801
- const libName = toFileNameLowerCase(libReference.fileName);
118802
- const libFileName = libMap.get(libName);
118803
- return { libName, libFileName };
118776
+ const libName = getLibNameFromLibReference(libReference);
118777
+ return libMap.get(libName);
118804
118778
  }
118805
118779
  function isReferencedFile(reason) {
118806
118780
  switch (reason == null ? void 0 : reason.kind) {
@@ -119043,6 +119017,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119043
119017
  let classifiableNames;
119044
119018
  const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
119045
119019
  let fileReasons = createMultiMap();
119020
+ let filesWithReferencesProcessed;
119021
+ let fileReasonsToChain;
119022
+ let reasonToRelatedInfo;
119046
119023
  const cachedBindAndCheckDiagnosticsForFile = {};
119047
119024
  const cachedDeclarationDiagnosticsForFile = {};
119048
119025
  let resolvedTypeReferenceDirectives = createModeAwareCache();
@@ -119074,6 +119051,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119074
119051
  const getDefaultLibraryFileName = memoize(() => host.getDefaultLibFileName(options));
119075
119052
  const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(getDefaultLibraryFileName());
119076
119053
  const programDiagnostics = createDiagnosticCollection();
119054
+ let lazyProgramDiagnosticExplainingFile = [];
119077
119055
  const currentDirectory = host.getCurrentDirectory();
119078
119056
  const supportedExtensions = getSupportedExtensions(options);
119079
119057
  const supportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
@@ -119280,6 +119258,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119280
119258
  files = stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
119281
119259
  processingDefaultLibFiles = void 0;
119282
119260
  processingOtherFiles = void 0;
119261
+ filesWithReferencesProcessed = void 0;
119283
119262
  }
119284
119263
  if (oldProgram && host.onReleaseOldSourceFile) {
119285
119264
  const oldSourceFiles = oldProgram.getSourceFiles();
@@ -119402,24 +119381,64 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119402
119381
  writeFile: writeFile2
119403
119382
  };
119404
119383
  onProgramCreateComplete();
119405
- fileProcessingDiagnostics == null ? void 0 : fileProcessingDiagnostics.forEach((diagnostic) => {
119406
- switch (diagnostic.kind) {
119407
- case 1 /* FilePreprocessingFileExplainingDiagnostic */:
119408
- return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || emptyArray));
119409
- case 0 /* FilePreprocessingReferencedDiagnostic */:
119410
- const { file, pos, end } = getReferencedFileLocation(program, diagnostic.reason);
119411
- return programDiagnostics.add(createFileDiagnostic(file, Debug.checkDefined(pos), Debug.checkDefined(end) - pos, diagnostic.diagnostic, ...diagnostic.args || emptyArray));
119412
- case 2 /* ResolutionDiagnostics */:
119413
- return diagnostic.diagnostics.forEach((d) => programDiagnostics.add(d));
119414
- default:
119415
- Debug.assertNever(diagnostic);
119416
- }
119417
- });
119418
119384
  verifyCompilerOptions();
119419
119385
  mark("afterProgram");
119420
119386
  measure("Program", "beforeProgram", "afterProgram");
119421
119387
  (_p = tracing) == null ? void 0 : _p.pop();
119422
119388
  return program;
119389
+ function updateAndGetProgramDiagnostics() {
119390
+ if (lazyProgramDiagnosticExplainingFile) {
119391
+ fileProcessingDiagnostics == null ? void 0 : fileProcessingDiagnostics.forEach((diagnostic) => {
119392
+ switch (diagnostic.kind) {
119393
+ case 1 /* FilePreprocessingFileExplainingDiagnostic */:
119394
+ return programDiagnostics.add(
119395
+ createDiagnosticExplainingFile(
119396
+ diagnostic.file && getSourceFileByPath(diagnostic.file),
119397
+ diagnostic.fileProcessingReason,
119398
+ diagnostic.diagnostic,
119399
+ diagnostic.args || emptyArray
119400
+ )
119401
+ );
119402
+ case 0 /* FilePreprocessingLibReferenceDiagnostic */:
119403
+ return programDiagnostics.add(filePreprocessingLibreferenceDiagnostic(diagnostic));
119404
+ case 2 /* ResolutionDiagnostics */:
119405
+ return diagnostic.diagnostics.forEach((d) => programDiagnostics.add(d));
119406
+ default:
119407
+ Debug.assertNever(diagnostic);
119408
+ }
119409
+ });
119410
+ lazyProgramDiagnosticExplainingFile.forEach(
119411
+ ({ file, diagnostic, args }) => programDiagnostics.add(
119412
+ createDiagnosticExplainingFile(
119413
+ file,
119414
+ /*fileProcessingReason*/
119415
+ void 0,
119416
+ diagnostic,
119417
+ args
119418
+ )
119419
+ )
119420
+ );
119421
+ lazyProgramDiagnosticExplainingFile = void 0;
119422
+ fileReasonsToChain = void 0;
119423
+ reasonToRelatedInfo = void 0;
119424
+ }
119425
+ return programDiagnostics;
119426
+ }
119427
+ function filePreprocessingLibreferenceDiagnostic({ reason }) {
119428
+ const { file, pos, end } = getReferencedFileLocation(program, reason);
119429
+ const libReference = file.libReferenceDirectives[reason.index];
119430
+ const libName = getLibNameFromLibReference(libReference);
119431
+ const unqualifiedLibName = removeSuffix(removePrefix(libName, "lib."), ".d.ts");
119432
+ const suggestion = getSpellingSuggestion(unqualifiedLibName, libs, identity);
119433
+ return createFileDiagnostic(
119434
+ file,
119435
+ Debug.checkDefined(pos),
119436
+ Debug.checkDefined(end) - pos,
119437
+ suggestion ? Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : Diagnostics.Cannot_find_lib_definition_for_0,
119438
+ libName,
119439
+ suggestion
119440
+ );
119441
+ }
119423
119442
  function getResolvedModule(file, moduleName, mode) {
119424
119443
  var _a2;
119425
119444
  return (_a2 = resolvedModules == null ? void 0 : resolvedModules.get(file.path)) == null ? void 0 : _a2.get(moduleName, mode);
@@ -120112,7 +120131,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120112
120131
  if (skipTypeChecking(sourceFile, options, program)) {
120113
120132
  return emptyArray;
120114
120133
  }
120115
- const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
120134
+ const programDiagnosticsInFile = updateAndGetProgramDiagnostics().getDiagnostics(sourceFile.fileName);
120116
120135
  if (!((_a2 = sourceFile.commentDirectives) == null ? void 0 : _a2.length)) {
120117
120136
  return programDiagnosticsInFile;
120118
120137
  }
@@ -120459,16 +120478,16 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120459
120478
  }
120460
120479
  function getOptionsDiagnostics() {
120461
120480
  return sortAndDeduplicateDiagnostics(concatenate(
120462
- programDiagnostics.getGlobalDiagnostics(),
120481
+ updateAndGetProgramDiagnostics().getGlobalDiagnostics(),
120463
120482
  getOptionsDiagnosticsOfConfigFile()
120464
120483
  ));
120465
120484
  }
120466
120485
  function getOptionsDiagnosticsOfConfigFile() {
120467
120486
  if (!options.configFile)
120468
120487
  return emptyArray;
120469
- let diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName);
120488
+ let diagnostics = updateAndGetProgramDiagnostics().getDiagnostics(options.configFile.fileName);
120470
120489
  forEachResolvedProjectReference2((resolvedRef) => {
120471
- diagnostics = concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName));
120490
+ diagnostics = concatenate(diagnostics, updateAndGetProgramDiagnostics().getDiagnostics(resolvedRef.sourceFile.fileName));
120472
120491
  });
120473
120492
  return diagnostics;
120474
120493
  }
@@ -120642,7 +120661,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120642
120661
  }
120643
120662
  function getLibFileFromReference(ref) {
120644
120663
  var _a2;
120645
- const { libFileName } = getLibFileNameFromLibReference(ref);
120664
+ const libFileName = getLibFileNameFromLibReference(ref);
120646
120665
  const actualFileName = libFileName && ((_a2 = resolvedLibReferences == null ? void 0 : resolvedLibReferences.get(libFileName)) == null ? void 0 : _a2.actual);
120647
120666
  return actualFileName !== void 0 ? getSourceFile(actualFileName) : void 0;
120648
120667
  }
@@ -120780,8 +120799,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120780
120799
  const originalFileName = fileName;
120781
120800
  if (filesByName.has(path)) {
120782
120801
  const file2 = filesByName.get(path);
120783
- addFileIncludeReason(file2 || void 0, reason);
120784
- if (file2 && !(options.forceConsistentCasingInFileNames === false)) {
120802
+ const addedReason = addFileIncludeReason(
120803
+ file2 || void 0,
120804
+ reason,
120805
+ /*checkExisting*/
120806
+ true
120807
+ );
120808
+ if (file2 && addedReason && !(options.forceConsistentCasingInFileNames === false)) {
120785
120809
  const checkedName = file2.fileName;
120786
120810
  const isRedirect = toPath3(checkedName) !== toPath3(fileName);
120787
120811
  if (isRedirect) {
@@ -120844,7 +120868,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120844
120868
  const dupFile = createRedirectedSourceFile(fileFromPackageId, file, fileName, path, toPath3(fileName), originalFileName, sourceFileOptions);
120845
120869
  redirectTargetsMap.add(fileFromPackageId.path, fileName);
120846
120870
  addFileToFilesByName(dupFile, path, fileName, redirectedPath);
120847
- addFileIncludeReason(dupFile, reason);
120871
+ addFileIncludeReason(
120872
+ dupFile,
120873
+ reason,
120874
+ /*checkExisting*/
120875
+ false
120876
+ );
120848
120877
  sourceFileToPackageName.set(path, packageIdToPackageName(packageId));
120849
120878
  processingOtherFiles.push(dupFile);
120850
120879
  return dupFile;
@@ -120862,7 +120891,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120862
120891
  file.originalFileName = originalFileName;
120863
120892
  file.packageJsonLocations = ((_a2 = sourceFileOptions.packageJsonLocations) == null ? void 0 : _a2.length) ? sourceFileOptions.packageJsonLocations : void 0;
120864
120893
  file.packageJsonScope = sourceFileOptions.packageJsonScope;
120865
- addFileIncludeReason(file, reason);
120894
+ addFileIncludeReason(
120895
+ file,
120896
+ reason,
120897
+ /*checkExisting*/
120898
+ false
120899
+ );
120866
120900
  if (host.useCaseSensitiveFileNames()) {
120867
120901
  const pathLowerCase = toFileNameLowerCase(path);
120868
120902
  const existingFile = filesByNameIgnoreCase.get(pathLowerCase);
@@ -120886,12 +120920,16 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120886
120920
  } else {
120887
120921
  processingOtherFiles.push(file);
120888
120922
  }
120923
+ (filesWithReferencesProcessed ?? (filesWithReferencesProcessed = /* @__PURE__ */ new Set())).add(file.path);
120889
120924
  }
120890
120925
  return file;
120891
120926
  }
120892
- function addFileIncludeReason(file, reason) {
120893
- if (file)
120927
+ function addFileIncludeReason(file, reason, checkExisting) {
120928
+ if (file && (!checkExisting || !isReferencedFile(reason) || !(filesWithReferencesProcessed == null ? void 0 : filesWithReferencesProcessed.has(reason.file)))) {
120894
120929
  fileReasons.add(file.path, reason);
120930
+ return true;
120931
+ }
120932
+ return false;
120895
120933
  }
120896
120934
  function addFileToFilesByName(file, path, fileName, redirectedPath) {
120897
120935
  if (redirectedPath) {
@@ -121121,7 +121159,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121121
121159
  }
121122
121160
  function processLibReferenceDirectives(file) {
121123
121161
  forEach(file.libReferenceDirectives, (libReference, index) => {
121124
- const { libName, libFileName } = getLibFileNameFromLibReference(libReference);
121162
+ const libFileName = getLibFileNameFromLibReference(libReference);
121125
121163
  if (libFileName) {
121126
121164
  processRootFile(
121127
121165
  pathForLibFile(libFileName),
@@ -121132,15 +121170,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121132
121170
  { kind: 7 /* LibReferenceDirective */, file: file.path, index }
121133
121171
  );
121134
121172
  } else {
121135
- const unqualifiedLibName = removeSuffix(removePrefix(libName, "lib."), ".d.ts");
121136
- const suggestion = getSpellingSuggestion(unqualifiedLibName, libs, identity);
121137
- const diagnostic = suggestion ? Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : Diagnostics.Cannot_find_lib_definition_for_0;
121138
- const args = suggestion ? [libName, suggestion] : [libName];
121139
121173
  (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
121140
- kind: 0 /* FilePreprocessingReferencedDiagnostic */,
121141
- reason: { kind: 7 /* LibReferenceDirective */, file: file.path, index },
121142
- diagnostic,
121143
- args
121174
+ kind: 0 /* FilePreprocessingLibReferenceDiagnostic */,
121175
+ reason: { kind: 7 /* LibReferenceDirective */, file: file.path, index }
121144
121176
  });
121145
121177
  }
121146
121178
  });
@@ -121201,7 +121233,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121201
121233
  if (!sourceFile.isDeclarationFile) {
121202
121234
  const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
121203
121235
  if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
121204
- addProgramDiagnosticExplainingFile(
121236
+ addLazyProgramDiagnosticExplainingFile(
121205
121237
  sourceFile,
121206
121238
  Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files,
121207
121239
  [sourceFile.fileName, rootDirectory]
@@ -121331,7 +121363,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121331
121363
  const rootPaths = new Set(rootNames.map(toPath3));
121332
121364
  for (const file of files) {
121333
121365
  if (sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
121334
- addProgramDiagnosticExplainingFile(
121366
+ addLazyProgramDiagnosticExplainingFile(
121335
121367
  file,
121336
121368
  Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern,
121337
121369
  [file.fileName, options.configFilePath || ""]
@@ -121694,31 +121726,90 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121694
121726
  });
121695
121727
  }
121696
121728
  function createDiagnosticExplainingFile(file, fileProcessingReason, diagnostic, args) {
121697
- var _a2;
121729
+ let seenReasons;
121730
+ const reasons = file && fileReasons.get(file.path);
121698
121731
  let fileIncludeReasons;
121699
121732
  let relatedInfo;
121700
121733
  let locationReason = isReferencedFile(fileProcessingReason) ? fileProcessingReason : void 0;
121701
- if (file)
121702
- (_a2 = fileReasons.get(file.path)) == null ? void 0 : _a2.forEach(processReason);
121734
+ let fileIncludeReasonDetails;
121735
+ let redirectInfo;
121736
+ let cachedChain = file && (fileReasonsToChain == null ? void 0 : fileReasonsToChain.get(file.path));
121737
+ let chain;
121738
+ if (cachedChain) {
121739
+ if (cachedChain.fileIncludeReasonDetails) {
121740
+ seenReasons = new Set(reasons);
121741
+ reasons == null ? void 0 : reasons.forEach(populateRelatedInfo);
121742
+ } else {
121743
+ reasons == null ? void 0 : reasons.forEach(processReason);
121744
+ }
121745
+ redirectInfo = cachedChain.redirectInfo;
121746
+ } else {
121747
+ reasons == null ? void 0 : reasons.forEach(processReason);
121748
+ redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, getCompilerOptionsForFile(file));
121749
+ }
121703
121750
  if (fileProcessingReason)
121704
121751
  processReason(fileProcessingReason);
121705
- if (locationReason && (fileIncludeReasons == null ? void 0 : fileIncludeReasons.length) === 1)
121706
- fileIncludeReasons = void 0;
121752
+ const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
121753
+ if (locationReason && (seenReasons == null ? void 0 : seenReasons.size) === 1)
121754
+ seenReasons = void 0;
121755
+ if (seenReasons && cachedChain) {
121756
+ if (cachedChain.details && !processedExtraReason) {
121757
+ chain = chainDiagnosticMessages(cachedChain.details, diagnostic, ...args || emptyArray);
121758
+ } else if (cachedChain.fileIncludeReasonDetails) {
121759
+ if (!processedExtraReason) {
121760
+ if (!cachedFileIncludeDetailsHasProcessedExtraReason()) {
121761
+ fileIncludeReasonDetails = cachedChain.fileIncludeReasonDetails;
121762
+ } else {
121763
+ fileIncludeReasons = cachedChain.fileIncludeReasonDetails.next.slice(0, reasons.length);
121764
+ }
121765
+ } else {
121766
+ if (!cachedFileIncludeDetailsHasProcessedExtraReason()) {
121767
+ fileIncludeReasons = [...cachedChain.fileIncludeReasonDetails.next, fileIncludeReasons[0]];
121768
+ } else {
121769
+ fileIncludeReasons = append(cachedChain.fileIncludeReasonDetails.next.slice(0, reasons.length), fileIncludeReasons[0]);
121770
+ }
121771
+ }
121772
+ }
121773
+ }
121774
+ if (!chain) {
121775
+ if (!fileIncludeReasonDetails)
121776
+ fileIncludeReasonDetails = seenReasons && chainDiagnosticMessages(fileIncludeReasons, Diagnostics.The_file_is_in_the_program_because_Colon);
121777
+ chain = chainDiagnosticMessages(
121778
+ redirectInfo ? fileIncludeReasonDetails ? [fileIncludeReasonDetails, ...redirectInfo] : redirectInfo : fileIncludeReasonDetails,
121779
+ diagnostic,
121780
+ ...args || emptyArray
121781
+ );
121782
+ }
121783
+ if (file) {
121784
+ if (cachedChain) {
121785
+ if (!cachedChain.fileIncludeReasonDetails || !processedExtraReason && fileIncludeReasonDetails) {
121786
+ cachedChain.fileIncludeReasonDetails = fileIncludeReasonDetails;
121787
+ }
121788
+ } else {
121789
+ (fileReasonsToChain ?? (fileReasonsToChain = /* @__PURE__ */ new Map())).set(file.path, cachedChain = { fileIncludeReasonDetails, redirectInfo });
121790
+ }
121791
+ if (!cachedChain.details && !processedExtraReason)
121792
+ cachedChain.details = chain.next;
121793
+ }
121707
121794
  const location = locationReason && getReferencedFileLocation(program, locationReason);
121708
- const fileIncludeReasonDetails = fileIncludeReasons && chainDiagnosticMessages(fileIncludeReasons, Diagnostics.The_file_is_in_the_program_because_Colon);
121709
- const optionsForFile = file && getCompilerOptionsForFile(file) || options;
121710
- const redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, optionsForFile);
121711
- const chain = chainDiagnosticMessages(redirectInfo ? fileIncludeReasonDetails ? [fileIncludeReasonDetails, ...redirectInfo] : redirectInfo : fileIncludeReasonDetails, diagnostic, ...args || emptyArray);
121712
121795
  return location && isReferenceFileLocation(location) ? createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : createCompilerDiagnosticFromMessageChain(chain, relatedInfo);
121713
121796
  function processReason(reason) {
121714
- (fileIncludeReasons || (fileIncludeReasons = [])).push(fileIncludeReasonToDiagnostics(program, reason));
121797
+ if (seenReasons == null ? void 0 : seenReasons.has(reason))
121798
+ return;
121799
+ (seenReasons ?? (seenReasons = /* @__PURE__ */ new Set())).add(reason);
121800
+ (fileIncludeReasons ?? (fileIncludeReasons = [])).push(fileIncludeReasonToDiagnostics(program, reason));
121801
+ populateRelatedInfo(reason);
121802
+ }
121803
+ function populateRelatedInfo(reason) {
121715
121804
  if (!locationReason && isReferencedFile(reason)) {
121716
121805
  locationReason = reason;
121717
121806
  } else if (locationReason !== reason) {
121718
- relatedInfo = append(relatedInfo, fileIncludeReasonToRelatedInformation(reason));
121807
+ relatedInfo = append(relatedInfo, getFileIncludeReasonToRelatedInformation(reason));
121719
121808
  }
121720
- if (reason === fileProcessingReason)
121721
- fileProcessingReason = void 0;
121809
+ }
121810
+ function cachedFileIncludeDetailsHasProcessedExtraReason() {
121811
+ var _a2;
121812
+ return ((_a2 = cachedChain.fileIncludeReasonDetails.next) == null ? void 0 : _a2.length) !== (reasons == null ? void 0 : reasons.length);
121722
121813
  }
121723
121814
  }
121724
121815
  function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
@@ -121730,14 +121821,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121730
121821
  args
121731
121822
  });
121732
121823
  }
121733
- function addProgramDiagnosticExplainingFile(file, diagnostic, args) {
121734
- programDiagnostics.add(createDiagnosticExplainingFile(
121735
- file,
121736
- /*fileProcessingReason*/
121737
- void 0,
121738
- diagnostic,
121739
- args
121740
- ));
121824
+ function addLazyProgramDiagnosticExplainingFile(file, diagnostic, args) {
121825
+ lazyProgramDiagnosticExplainingFile.push({ file, diagnostic, args });
121826
+ }
121827
+ function getFileIncludeReasonToRelatedInformation(reason) {
121828
+ let relatedInfo = reasonToRelatedInfo == null ? void 0 : reasonToRelatedInfo.get(reason);
121829
+ if (relatedInfo === void 0)
121830
+ (reasonToRelatedInfo ?? (reasonToRelatedInfo = /* @__PURE__ */ new Map())).set(reason, relatedInfo = fileIncludeReasonToRelatedInformation(reason) ?? false);
121831
+ return relatedInfo || void 0;
121741
121832
  }
121742
121833
  function fileIncludeReasonToRelatedInformation(reason) {
121743
121834
  if (isReferencedFile(reason)) {
@@ -125972,6 +126063,7 @@ function createWatchProgram(host) {
125972
126063
  });
125973
126064
  parsedConfigs = void 0;
125974
126065
  }
126066
+ builderProgram = void 0;
125975
126067
  }
125976
126068
  function getResolutionCache() {
125977
126069
  return resolutionCache;