@typescript-deploys/pr-build 5.5.0-pr-55267-165 → 5.6.0-pr-58760-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
@@ -17,8 +17,8 @@ and limitations under the License.
17
17
  "use strict";
18
18
 
19
19
  // src/compiler/corePublic.ts
20
- var versionMajorMinor = "5.5";
21
- var version = `${versionMajorMinor}.0-insiders.20240531`;
20
+ var versionMajorMinor = "5.6";
21
+ var version = `${versionMajorMinor}.0-insiders.20240603`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -19329,6 +19329,12 @@ function unwrapParenthesizedExpression(o) {
19329
19329
  }
19330
19330
  return o;
19331
19331
  }
19332
+ function unwrapParenthesizedType(o) {
19333
+ while (o.kind === 196 /* ParenthesizedType */) {
19334
+ o = o.type;
19335
+ }
19336
+ return o;
19337
+ }
19332
19338
  function hasInferredType(node) {
19333
19339
  Debug.type(node);
19334
19340
  switch (node.kind) {
@@ -49284,7 +49290,7 @@ function createTypeChecker(host) {
49284
49290
  return noMappedTypes && mappedType !== type ? void 0 : mappedType;
49285
49291
  }
49286
49292
  function setTextRange2(context, range, location) {
49287
- if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
49293
+ if (!nodeIsSynthesized(range) || !(range.flags & 16 /* Synthesized */) || !context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(getOriginalNode(range))) {
49288
49294
  range = factory.cloneNode(range);
49289
49295
  }
49290
49296
  if (range === location) return range;
@@ -50223,7 +50229,8 @@ function createTypeChecker(host) {
50223
50229
  const getterDeclaration = getDeclarationOfKind(propertySymbol, 177 /* GetAccessor */);
50224
50230
  const getterSignature = getSignatureFromDeclaration(getterDeclaration);
50225
50231
  typeElements.push(
50226
- setCommentRange(
50232
+ setCommentRange2(
50233
+ context,
50227
50234
  signatureToSignatureDeclarationHelper(getterSignature, 177 /* GetAccessor */, context, { name: propertyName }),
50228
50235
  getterDeclaration
50229
50236
  )
@@ -50231,7 +50238,8 @@ function createTypeChecker(host) {
50231
50238
  const setterDeclaration = getDeclarationOfKind(propertySymbol, 178 /* SetAccessor */);
50232
50239
  const setterSignature = getSignatureFromDeclaration(setterDeclaration);
50233
50240
  typeElements.push(
50234
- setCommentRange(
50241
+ setCommentRange2(
50242
+ context,
50235
50243
  signatureToSignatureDeclarationHelper(setterSignature, 178 /* SetAccessor */, context, { name: propertyName }),
50236
50244
  setterDeclaration
50237
50245
  )
@@ -50289,11 +50297,17 @@ function createTypeChecker(host) {
50289
50297
  setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
50290
50298
  }
50291
50299
  } else if (propertySymbol.valueDeclaration) {
50292
- setCommentRange(node, propertySymbol.valueDeclaration);
50300
+ setCommentRange2(context, node, propertySymbol.valueDeclaration);
50293
50301
  }
50294
50302
  return node;
50295
50303
  }
50296
50304
  }
50305
+ function setCommentRange2(context, node, range) {
50306
+ if (context.enclosingFile && context.enclosingFile === getSourceFileOfNode(range)) {
50307
+ return setCommentRange(node, range);
50308
+ }
50309
+ return node;
50310
+ }
50297
50311
  function mapToTypeNodes(types, context, isBareList) {
50298
50312
  if (some(types)) {
50299
50313
  if (checkTruncationLength(context)) {
@@ -51069,7 +51083,7 @@ function createTypeChecker(host) {
51069
51083
  return false;
51070
51084
  }
51071
51085
  function typeParameterToName(type, context) {
51072
- var _a, _b;
51086
+ var _a, _b, _c, _d;
51073
51087
  if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) {
51074
51088
  const cached = context.typeParameterNames.get(getTypeId(type));
51075
51089
  if (cached) {
@@ -51086,11 +51100,15 @@ function createTypeChecker(host) {
51086
51100
  if (!(result.kind & 80 /* Identifier */)) {
51087
51101
  return factory.createIdentifier("(Missing type parameter)");
51088
51102
  }
51103
+ const decl = (_b = (_a = type.symbol) == null ? void 0 : _a.declarations) == null ? void 0 : _b[0];
51104
+ if (decl && isTypeParameterDeclaration(decl)) {
51105
+ result = setTextRange2(context, result, decl.name);
51106
+ }
51089
51107
  if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
51090
51108
  const rawtext = result.escapedText;
51091
- let i = ((_a = context.typeParameterNamesByTextNextNameCount) == null ? void 0 : _a.get(rawtext)) || 0;
51109
+ let i = ((_c = context.typeParameterNamesByTextNextNameCount) == null ? void 0 : _c.get(rawtext)) || 0;
51092
51110
  let text = rawtext;
51093
- while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsOtherTypeParameterInScope(text, context, type)) {
51111
+ while (((_d = context.typeParameterNamesByText) == null ? void 0 : _d.has(text)) || typeParameterShadowsOtherTypeParameterInScope(text, context, type)) {
51094
51112
  i++;
51095
51113
  text = `${rawtext}_${i}`;
51096
51114
  }
@@ -51529,13 +51547,14 @@ function createTypeChecker(host) {
51529
51547
  }
51530
51548
  return node;
51531
51549
  }
51532
- return result === node ? setTextRange2(context, factory.cloneNode(result), node) : result;
51550
+ return result ? setTextRange2(context, result, node) : void 0;
51533
51551
  }
51534
51552
  function createRecoveryBoundary() {
51553
+ let trackedSymbols;
51535
51554
  let unreportedErrors;
51536
51555
  const oldTracker = context.tracker;
51537
51556
  const oldTrackedSymbols = context.trackedSymbols;
51538
- context.trackedSymbols = [];
51557
+ context.trackedSymbols = void 0;
51539
51558
  const oldEncounteredError = context.encounteredError;
51540
51559
  context.tracker = new SymbolTrackerImpl(context, {
51541
51560
  ...oldTracker.inner,
@@ -51555,17 +51574,7 @@ function createTypeChecker(host) {
51555
51574
  markError(() => oldTracker.reportNonSerializableProperty(name));
51556
51575
  },
51557
51576
  trackSymbol(sym, decl, meaning) {
51558
- const accessibility = isSymbolAccessible(
51559
- sym,
51560
- decl,
51561
- meaning,
51562
- /*shouldComputeAliasesToMakeVisible*/
51563
- false
51564
- );
51565
- if (accessibility.accessibility !== 0 /* Accessible */) {
51566
- (context.trackedSymbols ?? (context.trackedSymbols = [])).push([sym, decl, meaning]);
51567
- return true;
51568
- }
51577
+ (trackedSymbols ?? (trackedSymbols = [])).push([sym, decl, meaning]);
51569
51578
  return false;
51570
51579
  },
51571
51580
  moduleResolverHost: context.tracker.moduleResolverHost
@@ -51579,13 +51588,12 @@ function createTypeChecker(host) {
51579
51588
  (unreportedErrors ?? (unreportedErrors = [])).push(unreportedError);
51580
51589
  }
51581
51590
  function startRecoveryScope2() {
51582
- var _a;
51583
- const initialTrackedSymbolsTop = ((_a = context.trackedSymbols) == null ? void 0 : _a.length) ?? 0;
51591
+ const trackedSymbolsTop = (trackedSymbols == null ? void 0 : trackedSymbols.length) ?? 0;
51584
51592
  const unreportedErrorsTop = (unreportedErrors == null ? void 0 : unreportedErrors.length) ?? 0;
51585
51593
  return () => {
51586
51594
  hadError = false;
51587
- if (context.trackedSymbols) {
51588
- context.trackedSymbols.length = initialTrackedSymbolsTop;
51595
+ if (trackedSymbols) {
51596
+ trackedSymbols.length = trackedSymbolsTop;
51589
51597
  }
51590
51598
  if (unreportedErrors) {
51591
51599
  unreportedErrors.length = unreportedErrorsTop;
@@ -51594,14 +51602,13 @@ function createTypeChecker(host) {
51594
51602
  }
51595
51603
  function finalizeBoundary2() {
51596
51604
  context.tracker = oldTracker;
51597
- const newTrackedSymbols = context.trackedSymbols;
51598
51605
  context.trackedSymbols = oldTrackedSymbols;
51599
51606
  context.encounteredError = oldEncounteredError;
51600
51607
  unreportedErrors == null ? void 0 : unreportedErrors.forEach((fn) => fn());
51601
51608
  if (hadError) {
51602
51609
  return false;
51603
51610
  }
51604
- newTrackedSymbols == null ? void 0 : newTrackedSymbols.forEach(
51611
+ trackedSymbols == null ? void 0 : trackedSymbols.forEach(
51605
51612
  ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
51606
51613
  symbol,
51607
51614
  enclosingDeclaration,
@@ -51614,6 +51621,57 @@ function createTypeChecker(host) {
51614
51621
  function onEnterNewScope(node) {
51615
51622
  return enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
51616
51623
  }
51624
+ function tryVisitSimpleTypeNode(node) {
51625
+ const innerNode = unwrapParenthesizedType(node);
51626
+ switch (innerNode.kind) {
51627
+ case 183 /* TypeReference */:
51628
+ return tryVisitTypeReference(innerNode);
51629
+ case 186 /* TypeQuery */:
51630
+ return tryVisitTypeQuery(innerNode);
51631
+ case 199 /* IndexedAccessType */:
51632
+ return tryVisitIndexedAccess(innerNode);
51633
+ case 198 /* TypeOperator */:
51634
+ const typeOperatorNode = innerNode;
51635
+ if (typeOperatorNode.operator === 143 /* KeyOfKeyword */) {
51636
+ return tryVisitKeyOf(typeOperatorNode);
51637
+ }
51638
+ }
51639
+ return visitNode(node, visitExistingNodeTreeSymbols, isTypeNode);
51640
+ }
51641
+ function tryVisitIndexedAccess(node) {
51642
+ const resultObjectType = tryVisitSimpleTypeNode(node.objectType);
51643
+ if (resultObjectType === void 0) {
51644
+ return void 0;
51645
+ }
51646
+ return factory.updateIndexedAccessTypeNode(node, resultObjectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode));
51647
+ }
51648
+ function tryVisitKeyOf(node) {
51649
+ Debug.assertEqual(node.operator, 143 /* KeyOfKeyword */);
51650
+ const type = tryVisitSimpleTypeNode(node.type);
51651
+ if (type === void 0) {
51652
+ return void 0;
51653
+ }
51654
+ return factory.updateTypeOperatorNode(node, type);
51655
+ }
51656
+ function tryVisitTypeQuery(node) {
51657
+ const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
51658
+ if (!introducesError) {
51659
+ return factory.updateTypeQueryNode(
51660
+ node,
51661
+ exprName,
51662
+ visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
51663
+ );
51664
+ }
51665
+ const serializedName = serializeTypeName(
51666
+ context,
51667
+ node.exprName,
51668
+ /*isTypeOf*/
51669
+ true
51670
+ );
51671
+ if (serializedName) {
51672
+ return setTextRange2(context, serializedName, node.exprName);
51673
+ }
51674
+ }
51617
51675
  function tryVisitTypeReference(node) {
51618
51676
  if (canReuseTypeNode(context, node)) {
51619
51677
  const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
@@ -51747,13 +51805,13 @@ function createTypeChecker(host) {
51747
51805
  visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
51748
51806
  );
51749
51807
  }
51750
- if (isIndexedAccessTypeNode(node) && isTypeReferenceNode(node.objectType)) {
51751
- const objectType = tryVisitTypeReference(node.objectType);
51752
- if (!objectType) {
51808
+ if (isIndexedAccessTypeNode(node)) {
51809
+ const result = tryVisitIndexedAccess(node);
51810
+ if (!result) {
51753
51811
  hadError = true;
51754
51812
  return node;
51755
51813
  }
51756
- return factory.updateIndexedAccessTypeNode(node, objectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode));
51814
+ return result;
51757
51815
  }
51758
51816
  if (isTypeReferenceNode(node)) {
51759
51817
  const result = tryVisitTypeReference(node);
@@ -51785,12 +51843,7 @@ function createTypeChecker(host) {
51785
51843
  }
51786
51844
  }
51787
51845
  if (isFunctionLike(node) && !node.type || isPropertyDeclaration(node) && !node.type && !node.initializer || isPropertySignature(node) && !node.type && !node.initializer || isParameter(node) && !node.type && !node.initializer) {
51788
- let visited = visitEachChild(
51789
- node,
51790
- visitExistingNodeTreeSymbols,
51791
- /*context*/
51792
- void 0
51793
- );
51846
+ let visited = visitEachChild2(node, visitExistingNodeTreeSymbols);
51794
51847
  if (visited === node) {
51795
51848
  visited = setTextRange2(context, factory.cloneNode(node), node);
51796
51849
  }
@@ -51801,25 +51854,12 @@ function createTypeChecker(host) {
51801
51854
  return visited;
51802
51855
  }
51803
51856
  if (isTypeQueryNode(node)) {
51804
- const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
51805
- if (introducesError) {
51806
- const serializedName = serializeTypeName(
51807
- context,
51808
- node.exprName,
51809
- /*isTypeOf*/
51810
- true
51811
- );
51812
- if (serializedName) {
51813
- return setTextRange2(context, serializedName, node.exprName);
51814
- }
51857
+ const result = tryVisitTypeQuery(node);
51858
+ if (!result) {
51815
51859
  hadError = true;
51816
51860
  return node;
51817
51861
  }
51818
- return factory.updateTypeQueryNode(
51819
- node,
51820
- exprName,
51821
- visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
51822
- );
51862
+ return result;
51823
51863
  }
51824
51864
  if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
51825
51865
  const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
@@ -51851,12 +51891,7 @@ function createTypeChecker(host) {
51851
51891
  return factory.updateTypePredicateNode(node, node.assertsModifier, parameterName, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
51852
51892
  }
51853
51893
  if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
51854
- const visited = visitEachChild(
51855
- node,
51856
- visitExistingNodeTreeSymbols,
51857
- /*context*/
51858
- void 0
51859
- );
51894
+ const visited = visitEachChild2(node, visitExistingNodeTreeSymbols);
51860
51895
  const clone = setTextRange2(context, visited === node ? factory.cloneNode(node) : visited, node);
51861
51896
  const flags = getEmitFlags(clone);
51862
51897
  setEmitFlags(clone, flags | (context.flags & 1024 /* MultilineObjectLiterals */ && isTypeLiteralNode(node) ? 0 : 1 /* SingleLine */));
@@ -51889,22 +51924,37 @@ function createTypeChecker(host) {
51889
51924
  return node;
51890
51925
  }
51891
51926
  } else if (node.operator === 143 /* KeyOfKeyword */) {
51892
- if (isTypeReferenceNode(node.type)) {
51893
- const type = tryVisitTypeReference(node.type);
51894
- if (!type) {
51895
- hadError = true;
51896
- return node;
51927
+ const result = tryVisitKeyOf(node);
51928
+ if (!result) {
51929
+ hadError = true;
51930
+ return node;
51931
+ }
51932
+ return result;
51933
+ }
51934
+ }
51935
+ return visitEachChild2(node, visitExistingNodeTreeSymbols);
51936
+ function visitEachChild2(node2, visitor) {
51937
+ const nonlocalNode = !context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(node2);
51938
+ return visitEachChild(
51939
+ node2,
51940
+ visitor,
51941
+ /*context*/
51942
+ void 0,
51943
+ nonlocalNode ? visitNodesWithoutCopyingPositions : void 0
51944
+ );
51945
+ }
51946
+ function visitNodesWithoutCopyingPositions(nodes, visitor, test, start, count) {
51947
+ let result = visitNodes2(nodes, visitor, test, start, count);
51948
+ if (result) {
51949
+ if (result.pos !== -1 || result.end !== -1) {
51950
+ if (result === nodes) {
51951
+ result = factory.createNodeArray(nodes, nodes.hasTrailingComma);
51897
51952
  }
51898
- return factory.updateTypeOperatorNode(node, type);
51953
+ setTextRangePosEnd(result, -1, -1);
51899
51954
  }
51900
51955
  }
51956
+ return result;
51901
51957
  }
51902
- return visitEachChild(
51903
- node,
51904
- visitExistingNodeTreeSymbols,
51905
- /*context*/
51906
- void 0
51907
- );
51908
51958
  function getEffectiveDotDotDotForParameter(p) {
51909
51959
  return p.dotDotDotToken || (p.type && isJSDocVariadicType(p.type) ? factory.createToken(26 /* DotDotDotToken */) : void 0);
51910
51960
  }
@@ -56970,7 +57020,16 @@ function createTypeChecker(host) {
56970
57020
  }
56971
57021
  }
56972
57022
  function getApparentTypeOfIntersectionType(type, thisArgument) {
56973
- return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(
57023
+ if (type === thisArgument) {
57024
+ return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(
57025
+ type,
57026
+ thisArgument,
57027
+ /*needApparentType*/
57028
+ true
57029
+ ));
57030
+ }
57031
+ const key = `I${getTypeId(type)},${getTypeId(thisArgument)}`;
57032
+ return getCachedType(key) ?? setCachedType(key, getTypeWithThisArgument(
56974
57033
  type,
56975
57034
  thisArgument,
56976
57035
  /*needApparentType*/
@@ -112738,16 +112797,16 @@ function isBuildInfoFile(file) {
112738
112797
  function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit = false, onlyBuildInfo, includeBuildInfo) {
112739
112798
  const sourceFiles = isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
112740
112799
  const options = host.getCompilerOptions();
112741
- if (options.outFile) {
112742
- if (sourceFiles.length) {
112743
- const bundle = factory.createBundle(sourceFiles);
112744
- const result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
112745
- if (result) {
112746
- return result;
112800
+ if (!onlyBuildInfo) {
112801
+ if (options.outFile) {
112802
+ if (sourceFiles.length) {
112803
+ const bundle = factory.createBundle(sourceFiles);
112804
+ const result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
112805
+ if (result) {
112806
+ return result;
112807
+ }
112747
112808
  }
112748
- }
112749
- } else {
112750
- if (!onlyBuildInfo) {
112809
+ } else {
112751
112810
  for (const sourceFile of sourceFiles) {
112752
112811
  const result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
112753
112812
  if (result) {
@@ -112755,14 +112814,14 @@ function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDt
112755
112814
  }
112756
112815
  }
112757
112816
  }
112758
- if (includeBuildInfo) {
112759
- const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
112760
- if (buildInfoPath) return action(
112761
- { buildInfoPath },
112762
- /*sourceFileOrBundle*/
112763
- void 0
112764
- );
112765
- }
112817
+ }
112818
+ if (includeBuildInfo) {
112819
+ const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
112820
+ if (buildInfoPath) return action(
112821
+ { buildInfoPath },
112822
+ /*sourceFileOrBundle*/
112823
+ void 0
112824
+ );
112766
112825
  }
112767
112826
  }
112768
112827
  function getTsBuildInfoEmitOutputFilePath(options) {
@@ -112791,8 +112850,7 @@ function getOutputPathsForBundle(options, forceDtsPaths) {
112791
112850
  const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
112792
112851
  const declarationFilePath = forceDtsPaths || getEmitDeclarations(options) ? removeFileExtension(outPath) + ".d.ts" /* Dts */ : void 0;
112793
112852
  const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : void 0;
112794
- const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
112795
- return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath };
112853
+ return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath };
112796
112854
  }
112797
112855
  function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
112798
112856
  const options = host.getCompilerOptions();
@@ -112806,7 +112864,7 @@ function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
112806
112864
  const sourceMapFilePath = !jsFilePath || isJsonSourceFile(sourceFile) ? void 0 : getSourceMapFilePath(jsFilePath, options);
112807
112865
  const declarationFilePath = forceDtsPaths || getEmitDeclarations(options) && !isJsonFile ? getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : void 0;
112808
112866
  const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : void 0;
112809
- return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath: void 0 };
112867
+ return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath };
112810
112868
  }
112811
112869
  }
112812
112870
  function getSourceMapFilePath(jsFilePath, options) {
@@ -112855,7 +112913,7 @@ function createAddOutput() {
112855
112913
  }
112856
112914
  }
112857
112915
  function getSingleOutputFileNames(configFile, addOutput) {
112858
- const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath } = getOutputPathsForBundle(
112916
+ const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath } = getOutputPathsForBundle(
112859
112917
  configFile.options,
112860
112918
  /*forceDtsPaths*/
112861
112919
  false
@@ -112864,7 +112922,6 @@ function getSingleOutputFileNames(configFile, addOutput) {
112864
112922
  addOutput(sourceMapFilePath);
112865
112923
  addOutput(declarationFilePath);
112866
112924
  addOutput(declarationMapPath);
112867
- addOutput(buildInfoPath);
112868
112925
  }
112869
112926
  function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory2) {
112870
112927
  if (isDeclarationFileName(inputFileName)) return;
@@ -112915,8 +112972,8 @@ function getAllProjectOutputs(configFile, ignoreCase) {
112915
112972
  for (const inputFileName of configFile.fileNames) {
112916
112973
  getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory2);
112917
112974
  }
112918
- addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
112919
112975
  }
112976
+ addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
112920
112977
  return getOutputs();
112921
112978
  }
112922
112979
  function getFirstProjectOutput(configFile, ignoreCase) {
@@ -112945,7 +113002,7 @@ function getFirstProjectOutput(configFile, ignoreCase) {
112945
113002
  function emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) {
112946
113003
  return !!forceDtsEmit && !!emitOnly;
112947
113004
  }
112948
- function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, declarationTransformers }, emitOnly, onlyBuildInfo, forceDtsEmit) {
113005
+ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, declarationTransformers }, emitOnly, onlyBuildInfo, forceDtsEmit, skipBuildInfo) {
112949
113006
  var compilerOptions = host.getCompilerOptions();
112950
113007
  var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap || getAreDeclarationMapsEnabled(compilerOptions) ? [] : void 0;
112951
113008
  var emittedFilesList = compilerOptions.listEmittedFiles ? [] : void 0;
@@ -112961,7 +113018,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
112961
113018
  getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit),
112962
113019
  forceDtsEmit,
112963
113020
  onlyBuildInfo,
112964
- !targetSourceFile
113021
+ !targetSourceFile && !skipBuildInfo
112965
113022
  );
112966
113023
  exit();
112967
113024
  return {
@@ -112983,7 +113040,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
112983
113040
  (_f = tracing) == null ? void 0 : _f.pop();
112984
113041
  }
112985
113042
  function emitBuildInfo(buildInfoPath) {
112986
- if (!buildInfoPath || targetSourceFile || emitSkipped) return;
113043
+ if (!buildInfoPath || targetSourceFile) return;
112987
113044
  if (host.isEmitBlocked(buildInfoPath)) {
112988
113045
  emitSkipped = true;
112989
113046
  return;
@@ -119936,7 +119993,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119936
119993
  }
119937
119994
  function emitBuildInfo(writeFileCallback) {
119938
119995
  var _a2, _b2;
119939
- Debug.assert(!options.outFile);
119940
119996
  (_a2 = tracing) == null ? void 0 : _a2.push(
119941
119997
  tracing.Phase.Emit,
119942
119998
  "emitBuildInfo",
@@ -119991,7 +120047,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119991
120047
  function getTypeChecker() {
119992
120048
  return typeChecker || (typeChecker = createTypeChecker(program));
119993
120049
  }
119994
- function emit(sourceFile, writeFileCallback, cancellationToken, emitOnly, transformers, forceDtsEmit) {
120050
+ function emit(sourceFile, writeFileCallback, cancellationToken, emitOnly, transformers, forceDtsEmit, skipBuildInfo) {
119995
120051
  var _a2, _b2;
119996
120052
  (_a2 = tracing) == null ? void 0 : _a2.push(
119997
120053
  tracing.Phase.Emit,
@@ -120000,14 +120056,25 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120000
120056
  /*separateBeginAndEnd*/
120001
120057
  true
120002
120058
  );
120003
- const result = runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnly, transformers, forceDtsEmit));
120059
+ const result = runWithCancellationToken(
120060
+ () => emitWorker(
120061
+ program,
120062
+ sourceFile,
120063
+ writeFileCallback,
120064
+ cancellationToken,
120065
+ emitOnly,
120066
+ transformers,
120067
+ forceDtsEmit,
120068
+ skipBuildInfo
120069
+ )
120070
+ );
120004
120071
  (_b2 = tracing) == null ? void 0 : _b2.pop();
120005
120072
  return result;
120006
120073
  }
120007
120074
  function isEmitBlocked(emitFileName) {
120008
120075
  return hasEmitBlockingDiagnostics.has(toPath3(emitFileName));
120009
120076
  }
120010
- function emitWorker(program2, sourceFile, writeFileCallback, cancellationToken, emitOnly, customTransformers, forceDtsEmit) {
120077
+ function emitWorker(program2, sourceFile, writeFileCallback, cancellationToken, emitOnly, customTransformers, forceDtsEmit, skipBuildInfo) {
120011
120078
  if (!forceDtsEmit) {
120012
120079
  const result = handleNoEmitOptions(program2, sourceFile, writeFileCallback, cancellationToken);
120013
120080
  if (result) return result;
@@ -120029,7 +120096,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120029
120096
  emitOnly,
120030
120097
  /*onlyBuildInfo*/
120031
120098
  false,
120032
- forceDtsEmit
120099
+ forceDtsEmit,
120100
+ skipBuildInfo
120033
120101
  )
120034
120102
  );
120035
120103
  mark("afterEmit");
@@ -122161,7 +122229,7 @@ function handleNoEmitOptions(program, sourceFile, writeFile2, cancellationToken)
122161
122229
  const options = program.getCompilerOptions();
122162
122230
  if (options.noEmit) {
122163
122231
  program.getSemanticDiagnostics(sourceFile, cancellationToken);
122164
- return sourceFile || options.outFile ? emitSkippedWithNoDiagnostics : program.emitBuildInfo(writeFile2, cancellationToken);
122232
+ return sourceFile ? emitSkippedWithNoDiagnostics : program.emitBuildInfo(writeFile2, cancellationToken);
122165
122233
  }
122166
122234
  if (!options.noEmitOnError) return void 0;
122167
122235
  let diagnostics = [
@@ -122179,7 +122247,7 @@ function handleNoEmitOptions(program, sourceFile, writeFile2, cancellationToken)
122179
122247
  }
122180
122248
  if (!diagnostics.length) return void 0;
122181
122249
  let emittedFiles;
122182
- if (!sourceFile && !options.outFile) {
122250
+ if (!sourceFile) {
122183
122251
  const emitResult = program.emitBuildInfo(writeFile2, cancellationToken);
122184
122252
  if (emitResult.diagnostics) diagnostics = [...diagnostics, ...emitResult.diagnostics];
122185
122253
  emittedFiles = emitResult.emittedFiles;
@@ -122661,17 +122729,17 @@ function createBuilderProgramState(newProgram, oldState) {
122661
122729
  const compilerOptions = newProgram.getCompilerOptions();
122662
122730
  state.compilerOptions = compilerOptions;
122663
122731
  const outFilePath = compilerOptions.outFile;
122664
- if (!outFilePath) {
122665
- state.semanticDiagnosticsPerFile = /* @__PURE__ */ new Map();
122666
- } else if (compilerOptions.composite && (oldState == null ? void 0 : oldState.outSignature) && outFilePath === oldState.compilerOptions.outFile) {
122732
+ state.semanticDiagnosticsPerFile = /* @__PURE__ */ new Map();
122733
+ if (outFilePath && compilerOptions.composite && (oldState == null ? void 0 : oldState.outSignature) && outFilePath === oldState.compilerOptions.outFile) {
122667
122734
  state.outSignature = oldState.outSignature && getEmitSignatureFromOldSignature(compilerOptions, oldState.compilerOptions, oldState.outSignature);
122668
122735
  }
122669
122736
  state.changedFilesSet = /* @__PURE__ */ new Set();
122670
122737
  state.latestChangedDtsFile = compilerOptions.composite ? oldState == null ? void 0 : oldState.latestChangedDtsFile : void 0;
122671
122738
  const useOldState = BuilderState.canReuseOldState(state.referencedMap, oldState);
122672
122739
  const oldCompilerOptions = useOldState ? oldState.compilerOptions : void 0;
122673
- const canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && !compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122740
+ let canCopySemanticDiagnostics = useOldState && !compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122674
122741
  const canCopyEmitSignatures = compilerOptions.composite && (oldState == null ? void 0 : oldState.emitSignatures) && !outFilePath && !compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
122742
+ let canCopyEmitDiagnostics = true;
122675
122743
  if (useOldState) {
122676
122744
  (_a = oldState.changedFilesSet) == null ? void 0 : _a.forEach((value) => state.changedFilesSet.add(value));
122677
122745
  if (!outFilePath && ((_b = oldState.affectedFilesPendingEmit) == null ? void 0 : _b.size)) {
@@ -122679,6 +122747,10 @@ function createBuilderProgramState(newProgram, oldState) {
122679
122747
  state.seenAffectedFiles = /* @__PURE__ */ new Set();
122680
122748
  }
122681
122749
  state.programEmitPending = oldState.programEmitPending;
122750
+ if (outFilePath && state.changedFilesSet.size) {
122751
+ canCopySemanticDiagnostics = false;
122752
+ canCopyEmitDiagnostics = false;
122753
+ }
122682
122754
  } else {
122683
122755
  state.buildInfoEmitPending = true;
122684
122756
  }
@@ -122696,10 +122768,10 @@ function createBuilderProgramState(newProgram, oldState) {
122696
122768
  oldInfo.impliedFormat !== info.impliedFormat || // Referenced files changed
122697
122769
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) || // Referenced file was deleted in the new program
122698
122770
  newReferences && forEachKey(newReferences, (path) => !state.fileInfos.has(path) && oldState.fileInfos.has(path))) {
122699
- addFileToChangeSet(state, sourceFilePath);
122771
+ addFileToChangeSet(sourceFilePath);
122700
122772
  } else {
122701
122773
  const sourceFile = newProgram.getSourceFileByPath(sourceFilePath);
122702
- const emitDiagnostics = (_a2 = oldState.emitDiagnosticsPerFile) == null ? void 0 : _a2.get(sourceFilePath);
122774
+ const emitDiagnostics = canCopyEmitDiagnostics ? (_a2 = oldState.emitDiagnosticsPerFile) == null ? void 0 : _a2.get(sourceFilePath) : void 0;
122703
122775
  if (emitDiagnostics) {
122704
122776
  (state.emitDiagnosticsPerFile ?? (state.emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(
122705
122777
  sourceFilePath,
@@ -122728,16 +122800,16 @@ function createBuilderProgramState(newProgram, oldState) {
122728
122800
  });
122729
122801
  if (useOldState && forEachEntry(oldState.fileInfos, (info, sourceFilePath) => {
122730
122802
  if (state.fileInfos.has(sourceFilePath)) return false;
122731
- if (outFilePath || info.affectsGlobalScope) return true;
122803
+ if (info.affectsGlobalScope) return true;
122732
122804
  state.buildInfoEmitPending = true;
122733
- return false;
122805
+ return !!outFilePath;
122734
122806
  })) {
122735
122807
  BuilderState.getAllFilesExcludingDefaultLibraryFile(
122736
122808
  state,
122737
122809
  newProgram,
122738
122810
  /*firstSourceFile*/
122739
122811
  void 0
122740
- ).forEach((file) => addFileToChangeSet(state, file.resolvedPath));
122812
+ ).forEach((file) => addFileToChangeSet(file.resolvedPath));
122741
122813
  } else if (oldCompilerOptions) {
122742
122814
  const pendingEmitKind = compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions) ? getBuilderFileEmit(compilerOptions) : getPendingEmitKind(compilerOptions, oldCompilerOptions);
122743
122815
  if (pendingEmitKind !== 0 /* None */) {
@@ -122753,18 +122825,25 @@ function createBuilderProgramState(newProgram, oldState) {
122753
122825
  });
122754
122826
  Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
122755
122827
  state.seenAffectedFiles = state.seenAffectedFiles || /* @__PURE__ */ new Set();
122756
- state.buildInfoEmitPending = true;
122757
- } else {
122828
+ } else if (!state.changedFilesSet.size) {
122758
122829
  state.programEmitPending = state.programEmitPending ? state.programEmitPending | pendingEmitKind : pendingEmitKind;
122759
122830
  }
122831
+ state.buildInfoEmitPending = true;
122760
122832
  }
122761
122833
  }
122762
122834
  return state;
122763
- }
122764
- function addFileToChangeSet(state, path) {
122765
- state.changedFilesSet.add(path);
122766
- state.buildInfoEmitPending = true;
122767
- state.programEmitPending = void 0;
122835
+ function addFileToChangeSet(path) {
122836
+ state.changedFilesSet.add(path);
122837
+ if (outFilePath) {
122838
+ canCopySemanticDiagnostics = false;
122839
+ canCopyEmitDiagnostics = false;
122840
+ state.semanticDiagnosticsFromOldState = void 0;
122841
+ state.semanticDiagnosticsPerFile.clear();
122842
+ state.emitDiagnosticsPerFile = void 0;
122843
+ }
122844
+ state.buildInfoEmitPending = true;
122845
+ state.programEmitPending = void 0;
122846
+ }
122768
122847
  }
122769
122848
  function getEmitSignatureFromOldSignature(options, oldOptions, oldEmitSignature) {
122770
122849
  return !!options.declarationMap === !!oldOptions.declarationMap ? (
@@ -122837,6 +122916,7 @@ function backupBuilderProgramEmitState(state) {
122837
122916
  return {
122838
122917
  affectedFilesPendingEmit: state.affectedFilesPendingEmit && new Map(state.affectedFilesPendingEmit),
122839
122918
  seenEmittedFiles: state.seenEmittedFiles && new Map(state.seenEmittedFiles),
122919
+ seenProgramEmit: state.seenProgramEmit,
122840
122920
  programEmitPending: state.programEmitPending,
122841
122921
  emitSignatures: state.emitSignatures && new Map(state.emitSignatures),
122842
122922
  outSignature: state.outSignature,
@@ -122850,6 +122930,7 @@ function backupBuilderProgramEmitState(state) {
122850
122930
  function restoreBuilderProgramEmitState(state, savedEmitState) {
122851
122931
  state.affectedFilesPendingEmit = savedEmitState.affectedFilesPendingEmit;
122852
122932
  state.seenEmittedFiles = savedEmitState.seenEmittedFiles;
122933
+ state.seenProgramEmit = savedEmitState.seenProgramEmit;
122853
122934
  state.programEmitPending = savedEmitState.programEmitPending;
122854
122935
  state.emitSignatures = savedEmitState.emitSignatures;
122855
122936
  state.outSignature = savedEmitState.outSignature;
@@ -122858,6 +122939,10 @@ function restoreBuilderProgramEmitState(state, savedEmitState) {
122858
122939
  state.buildInfoEmitPending = savedEmitState.buildInfoEmitPending;
122859
122940
  state.emitDiagnosticsPerFile = savedEmitState.emitDiagnosticsPerFile;
122860
122941
  if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet;
122942
+ if (state.compilerOptions.outFile && state.changedFilesSet.size) {
122943
+ state.semanticDiagnosticsPerFile.clear();
122944
+ state.emitDiagnosticsPerFile = void 0;
122945
+ }
122861
122946
  }
122862
122947
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
122863
122948
  Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
@@ -122895,10 +122980,7 @@ function getNextAffectedFile(state, cancellationToken, host) {
122895
122980
  }
122896
122981
  const program = Debug.checkDefined(state.program);
122897
122982
  const compilerOptions = program.getCompilerOptions();
122898
- if (compilerOptions.outFile) {
122899
- Debug.assert(!state.semanticDiagnosticsPerFile);
122900
- return program;
122901
- }
122983
+ if (compilerOptions.outFile) return program;
122902
122984
  state.affectedFiles = BuilderState.getFilesAffectedByWithOldState(
122903
122985
  state,
122904
122986
  program,
@@ -122912,14 +122994,22 @@ function getNextAffectedFile(state, cancellationToken, host) {
122912
122994
  }
122913
122995
  }
122914
122996
  function clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles) {
122915
- var _a;
122916
- if (!((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size)) return;
122917
- if (!emitOnlyDtsFiles) return state.affectedFilesPendingEmit = void 0;
122918
- state.affectedFilesPendingEmit.forEach((emitKind, path) => {
122997
+ var _a, _b;
122998
+ if (!((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size) && !state.programEmitPending) return;
122999
+ if (!emitOnlyDtsFiles) {
123000
+ state.affectedFilesPendingEmit = void 0;
123001
+ state.programEmitPending = void 0;
123002
+ }
123003
+ (_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.forEach((emitKind, path) => {
122919
123004
  const pending = emitKind & 7 /* AllJs */;
122920
123005
  if (!pending) state.affectedFilesPendingEmit.delete(path);
122921
123006
  else state.affectedFilesPendingEmit.set(path, pending);
122922
123007
  });
123008
+ if (state.programEmitPending) {
123009
+ const pending = state.programEmitPending & 7 /* AllJs */;
123010
+ if (!pending) state.programEmitPending = void 0;
123011
+ else state.programEmitPending = pending;
123012
+ }
122923
123013
  }
122924
123014
  function getNextAffectedFilePendingEmit(state, emitOnlyDtsFiles) {
122925
123015
  var _a;
@@ -123111,24 +123201,21 @@ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, invalidateJsF
123111
123201
  );
123112
123202
  return void 0;
123113
123203
  }
123114
- function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
123204
+ function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
123115
123205
  return concatenate(
123116
- getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken),
123206
+ getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile),
123117
123207
  Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile)
123118
123208
  );
123119
123209
  }
123120
- function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken) {
123210
+ function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
123211
+ semanticDiagnosticsPerFile ?? (semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile);
123121
123212
  const path = sourceFile.resolvedPath;
123122
- if (state.semanticDiagnosticsPerFile) {
123123
- const cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
123124
- if (cachedDiagnostics) {
123125
- return filterSemanticDiagnostics(cachedDiagnostics, state.compilerOptions);
123126
- }
123213
+ const cachedDiagnostics = semanticDiagnosticsPerFile.get(path);
123214
+ if (cachedDiagnostics) {
123215
+ return filterSemanticDiagnostics(cachedDiagnostics, state.compilerOptions);
123127
123216
  }
123128
123217
  const diagnostics = Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
123129
- if (state.semanticDiagnosticsPerFile) {
123130
- state.semanticDiagnosticsPerFile.set(path, diagnostics);
123131
- }
123218
+ semanticDiagnosticsPerFile.set(path, diagnostics);
123132
123219
  return filterSemanticDiagnostics(diagnostics, state.compilerOptions);
123133
123220
  }
123134
123221
  function isProgramBundleEmitBuildInfo(info) {
@@ -123156,6 +123243,9 @@ function getBuildInfo2(state) {
123156
123243
  root,
123157
123244
  resolvedRoot: toResolvedRoot(),
123158
123245
  options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
123246
+ semanticDiagnosticsPerFile: convertToProgramBuildInfoDiagnostics(),
123247
+ emitDiagnosticsPerFile: convertToProgramBuildInfoEmitDiagnostics(),
123248
+ changeFileSet: toChangeFileSet(),
123159
123249
  outSignature: state.outSignature,
123160
123250
  latestChangedDtsFile,
123161
123251
  pendingEmit: !state.programEmitPending ? void 0 : (
@@ -123246,13 +123336,6 @@ function getBuildInfo2(state) {
123246
123336
  }
123247
123337
  }
123248
123338
  }
123249
- let changeFileSet;
123250
- if (state.changedFilesSet.size) {
123251
- for (const path of arrayFrom(state.changedFilesSet.keys()).sort(compareStringsCaseSensitive)) {
123252
- changeFileSet = append(changeFileSet, toFileId(path));
123253
- }
123254
- }
123255
- const emitDiagnosticsPerFile = convertToProgramBuildInfoEmitDiagnostics();
123256
123339
  const program = {
123257
123340
  fileNames,
123258
123341
  fileInfos,
@@ -123262,9 +123345,9 @@ function getBuildInfo2(state) {
123262
123345
  fileIdsList,
123263
123346
  referencedMap,
123264
123347
  semanticDiagnosticsPerFile,
123265
- emitDiagnosticsPerFile,
123348
+ emitDiagnosticsPerFile: convertToProgramBuildInfoEmitDiagnostics(),
123266
123349
  affectedFilesPendingEmit,
123267
- changeFileSet,
123350
+ changeFileSet: toChangeFileSet(),
123268
123351
  emitSignatures,
123269
123352
  latestChangedDtsFile
123270
123353
  };
@@ -123347,8 +123430,7 @@ function getBuildInfo2(state) {
123347
123430
  function convertToProgramBuildInfoDiagnostics() {
123348
123431
  let result;
123349
123432
  state.fileInfos.forEach((_value, key) => {
123350
- var _a2;
123351
- const value = (_a2 = state.semanticDiagnosticsPerFile) == null ? void 0 : _a2.get(key);
123433
+ const value = state.semanticDiagnosticsPerFile.get(key);
123352
123434
  if (!value) {
123353
123435
  if (!state.changedFilesSet.has(key)) result = append(result, toFileId(key));
123354
123436
  } else if (value.length) {
@@ -123417,6 +123499,15 @@ function getBuildInfo2(state) {
123417
123499
  return result;
123418
123500
  }) || array;
123419
123501
  }
123502
+ function toChangeFileSet() {
123503
+ let changeFileSet;
123504
+ if (state.changedFilesSet.size) {
123505
+ for (const path of arrayFrom(state.changedFilesSet.keys()).sort(compareStringsCaseSensitive)) {
123506
+ changeFileSet = append(changeFileSet, toFileId(path));
123507
+ }
123508
+ }
123509
+ return changeFileSet;
123510
+ }
123420
123511
  }
123421
123512
  function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
123422
123513
  let host;
@@ -123515,14 +123606,16 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123515
123606
  return emitSkippedWithNoDiagnostics;
123516
123607
  }
123517
123608
  function emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
123518
- var _a, _b, _c;
123609
+ var _a, _b, _c, _d;
123519
123610
  let affected = getNextAffectedFile(state, cancellationToken, host);
123520
123611
  const programEmitKind = getBuilderFileEmit(state.compilerOptions);
123521
123612
  let emitKind = emitOnlyDtsFiles ? programEmitKind & 24 /* AllDts */ : programEmitKind;
123522
123613
  if (!affected) {
123523
123614
  if (!state.compilerOptions.outFile) {
123524
123615
  const pendingAffectedFile = getNextAffectedFilePendingEmit(state, emitOnlyDtsFiles);
123525
- if (!pendingAffectedFile) {
123616
+ if (pendingAffectedFile) {
123617
+ ({ affectedFile: affected, emitKind } = pendingAffectedFile);
123618
+ } else {
123526
123619
  const pendingForDiagnostics = getNextPendingEmitDiagnosticsFile(state);
123527
123620
  if (pendingForDiagnostics) {
123528
123621
  (state.seenEmittedFiles ?? (state.seenEmittedFiles = /* @__PURE__ */ new Map())).set(pendingForDiagnostics.affectedFile.resolvedPath, pendingForDiagnostics.seenKind | 24 /* AllDts */);
@@ -123531,48 +123624,73 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123531
123624
  affected: pendingForDiagnostics.affectedFile
123532
123625
  };
123533
123626
  }
123534
- if (!state.buildInfoEmitPending) return void 0;
123535
- const affected2 = state.program;
123536
- const result2 = affected2.emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
123537
- state.buildInfoEmitPending = false;
123538
- return { result: result2, affected: affected2 };
123539
123627
  }
123540
- ({ affectedFile: affected, emitKind } = pendingAffectedFile);
123541
123628
  } else {
123542
- if (!state.programEmitPending) return void 0;
123543
- emitKind = state.programEmitPending;
123544
- if (emitOnlyDtsFiles) emitKind = emitKind & 24 /* AllDts */;
123545
- if (!emitKind) return void 0;
123546
- affected = state.program;
123629
+ if (state.programEmitPending) {
123630
+ emitKind = state.programEmitPending;
123631
+ if (emitOnlyDtsFiles) emitKind = emitKind & 24 /* AllDts */;
123632
+ if (emitKind) affected = state.program;
123633
+ }
123634
+ if (!affected && ((_a = state.emitDiagnosticsPerFile) == null ? void 0 : _a.size)) {
123635
+ const seenKind = state.seenProgramEmit || 0 /* None */;
123636
+ if (!(seenKind & 24 /* AllDts */)) {
123637
+ state.seenProgramEmit = 24 /* AllDts */ | seenKind;
123638
+ const diagnostics = [];
123639
+ state.emitDiagnosticsPerFile.forEach((d) => addRange(diagnostics, d));
123640
+ return {
123641
+ result: { emitSkipped: true, diagnostics },
123642
+ affected: state.program
123643
+ };
123644
+ }
123645
+ }
123646
+ }
123647
+ if (!affected) {
123648
+ if (!state.buildInfoEmitPending) return void 0;
123649
+ const affected2 = state.program;
123650
+ const result2 = affected2.emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
123651
+ state.buildInfoEmitPending = false;
123652
+ return { result: result2, affected: affected2 };
123547
123653
  }
123548
123654
  }
123549
123655
  let emitOnly;
123550
123656
  if (emitKind & 7 /* AllJs */) emitOnly = 0 /* Js */;
123551
123657
  if (emitKind & 24 /* AllDts */) emitOnly = emitOnly === void 0 ? 1 /* Dts */ : void 0;
123552
- if (affected === state.program) {
123553
- state.programEmitPending = state.changedFilesSet.size ? getPendingEmitKind(programEmitKind, emitKind) : state.programEmitPending ? getPendingEmitKind(state.programEmitPending, emitKind) : void 0;
123554
- }
123555
123658
  const result = state.program.emit(
123556
123659
  affected === state.program ? void 0 : affected,
123557
123660
  getWriteFileCallback(writeFile2, customTransformers),
123558
123661
  cancellationToken,
123559
123662
  emitOnly,
123560
- customTransformers
123663
+ customTransformers,
123664
+ /*forceDtsEmit*/
123665
+ void 0,
123666
+ /*skipBuildInfo*/
123667
+ true
123561
123668
  );
123562
123669
  if (affected !== state.program) {
123563
123670
  const affectedSourceFile = affected;
123564
123671
  state.seenAffectedFiles.add(affectedSourceFile.resolvedPath);
123565
123672
  if (state.affectedFilesIndex !== void 0) state.affectedFilesIndex++;
123566
123673
  state.buildInfoEmitPending = true;
123567
- const existing = ((_a = state.seenEmittedFiles) == null ? void 0 : _a.get(affectedSourceFile.resolvedPath)) || 0 /* None */;
123674
+ const existing = ((_b = state.seenEmittedFiles) == null ? void 0 : _b.get(affectedSourceFile.resolvedPath)) || 0 /* None */;
123568
123675
  (state.seenEmittedFiles ?? (state.seenEmittedFiles = /* @__PURE__ */ new Map())).set(affectedSourceFile.resolvedPath, emitKind | existing);
123569
- const existingPending = ((_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.get(affectedSourceFile.resolvedPath)) || programEmitKind;
123676
+ const existingPending = ((_c = state.affectedFilesPendingEmit) == null ? void 0 : _c.get(affectedSourceFile.resolvedPath)) || programEmitKind;
123570
123677
  const pendingKind = getPendingEmitKind(existingPending, emitKind | existing);
123571
123678
  if (pendingKind) (state.affectedFilesPendingEmit ?? (state.affectedFilesPendingEmit = /* @__PURE__ */ new Map())).set(affectedSourceFile.resolvedPath, pendingKind);
123572
- else (_c = state.affectedFilesPendingEmit) == null ? void 0 : _c.delete(affectedSourceFile.resolvedPath);
123679
+ else (_d = state.affectedFilesPendingEmit) == null ? void 0 : _d.delete(affectedSourceFile.resolvedPath);
123573
123680
  if (result.diagnostics.length) (state.emitDiagnosticsPerFile ?? (state.emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(affectedSourceFile.resolvedPath, result.diagnostics);
123574
123681
  } else {
123575
123682
  state.changedFilesSet.clear();
123683
+ state.programEmitPending = state.changedFilesSet.size ? getPendingEmitKind(programEmitKind, emitKind) : state.programEmitPending ? getPendingEmitKind(state.programEmitPending, emitKind) : void 0;
123684
+ state.seenProgramEmit = emitKind | (state.seenProgramEmit || 0 /* None */);
123685
+ let emitDiagnosticsPerFile;
123686
+ result.diagnostics.forEach((d) => {
123687
+ if (!d.file) return;
123688
+ let diagnostics = emitDiagnosticsPerFile == null ? void 0 : emitDiagnosticsPerFile.get(d.file.resolvedPath);
123689
+ if (!diagnostics) (emitDiagnosticsPerFile ?? (emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(d.file.resolvedPath, diagnostics = []);
123690
+ diagnostics.push(d);
123691
+ });
123692
+ if (emitDiagnosticsPerFile) state.emitDiagnosticsPerFile = emitDiagnosticsPerFile;
123693
+ state.buildInfoEmitPending = true;
123576
123694
  }
123577
123695
  return { result, affected };
123578
123696
  }
@@ -123694,28 +123812,37 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123694
123812
  state.buildInfoEmitPending = true;
123695
123813
  if (!result) continue;
123696
123814
  } else {
123697
- result = state.program.getSemanticDiagnostics(
123698
- /*sourceFile*/
123699
- void 0,
123700
- cancellationToken
123815
+ let diagnostics;
123816
+ const semanticDiagnosticsPerFile = /* @__PURE__ */ new Map();
123817
+ state.program.getSourceFiles().forEach(
123818
+ (sourceFile) => diagnostics = addRange(
123819
+ diagnostics,
123820
+ getSemanticDiagnosticsOfFile(
123821
+ state,
123822
+ sourceFile,
123823
+ cancellationToken,
123824
+ semanticDiagnosticsPerFile
123825
+ )
123826
+ )
123701
123827
  );
123828
+ state.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
123829
+ result = diagnostics || emptyArray;
123702
123830
  state.changedFilesSet.clear();
123703
123831
  state.programEmitPending = getBuilderFileEmit(state.compilerOptions);
123832
+ state.buildInfoEmitPending = true;
123704
123833
  }
123705
123834
  return { result, affected };
123706
123835
  }
123707
123836
  }
123708
123837
  function getSemanticDiagnostics(sourceFile, cancellationToken) {
123709
123838
  assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
123710
- const compilerOptions = Debug.checkDefined(state.program).getCompilerOptions();
123711
- if (compilerOptions.outFile) {
123712
- Debug.assert(!state.semanticDiagnosticsPerFile);
123713
- return Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
123714
- }
123715
123839
  if (sourceFile) {
123716
123840
  return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
123717
123841
  }
123718
- while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
123842
+ while (true) {
123843
+ const affectedResult = getSemanticDiagnosticsOfNextAffectedFile(cancellationToken);
123844
+ if (!affectedResult) break;
123845
+ if (affectedResult.affected === state.program) return affectedResult.result;
123719
123846
  }
123720
123847
  let diagnostics;
123721
123848
  for (const sourceFile2 of Debug.checkDefined(state.program).getSourceFiles()) {
@@ -123748,8 +123875,9 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123748
123875
  const filePaths = (_a = program.fileNames) == null ? void 0 : _a.map(toPathInBuildInfoDirectory);
123749
123876
  let filePathsSetList;
123750
123877
  const latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : void 0;
123878
+ const fileInfos = /* @__PURE__ */ new Map();
123879
+ const changedFilesSet = new Set(map(program.changeFileSet, toFilePath));
123751
123880
  if (isProgramBundleEmitBuildInfo(program)) {
123752
- const fileInfos = /* @__PURE__ */ new Map();
123753
123881
  program.fileInfos.forEach((fileInfo, index) => {
123754
123882
  const path = toFilePath(index + 1);
123755
123883
  fileInfos.set(path, isString(fileInfo) ? { version: fileInfo, signature: void 0, affectsGlobalScope: void 0, impliedFormat: void 0 } : fileInfo);
@@ -123757,13 +123885,16 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123757
123885
  state = {
123758
123886
  fileInfos,
123759
123887
  compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
123888
+ semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile),
123889
+ emitDiagnosticsPerFile: toPerFileEmitDiagnostics(program.emitDiagnosticsPerFile),
123890
+ hasReusableDiagnostic: true,
123891
+ changedFilesSet,
123760
123892
  latestChangedDtsFile,
123761
123893
  outSignature: program.outSignature,
123762
123894
  programEmitPending: program.pendingEmit === void 0 ? void 0 : toProgramEmitPending(program.pendingEmit, program.options)
123763
123895
  };
123764
123896
  } else {
123765
123897
  filePathsSetList = (_b = program.fileIdsList) == null ? void 0 : _b.map((fileIds) => new Set(fileIds.map(toFilePath)));
123766
- const fileInfos = /* @__PURE__ */ new Map();
123767
123898
  const emitSignatures = ((_c = program.options) == null ? void 0 : _c.composite) && !program.options.outFile ? /* @__PURE__ */ new Map() : void 0;
123768
123899
  program.fileInfos.forEach((fileInfo, index) => {
123769
123900
  const path = toFilePath(index + 1);
@@ -123784,13 +123915,12 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123784
123915
  );
123785
123916
  }
123786
123917
  });
123787
- const changedFilesSet = new Set(map(program.changeFileSet, toFilePath));
123788
123918
  const fullEmitForOptions = program.affectedFilesPendingEmit ? getBuilderFileEmit(program.options || {}) : void 0;
123789
123919
  state = {
123790
123920
  fileInfos,
123791
123921
  compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
123792
123922
  referencedMap: toManyToManyPathMap(program.referencedMap, program.options ?? {}),
123793
- semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile, fileInfos, changedFilesSet),
123923
+ semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile),
123794
123924
  emitDiagnosticsPerFile: toPerFileEmitDiagnostics(program.emitDiagnosticsPerFile),
123795
123925
  hasReusableDiagnostic: true,
123796
123926
  affectedFilesPendingEmit: program.affectedFilesPendingEmit && arrayToMap(program.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
@@ -123842,7 +123972,7 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123842
123972
  referenceMap.forEach(([fileId, fileIdListId]) => map2.set(toFilePath(fileId), toFilePathsSet(fileIdListId)));
123843
123973
  return map2;
123844
123974
  }
123845
- function toPerFileSemanticDiagnostics(diagnostics, fileInfos, changedFilesSet) {
123975
+ function toPerFileSemanticDiagnostics(diagnostics) {
123846
123976
  const semanticDiagnostics = new Map(
123847
123977
  mapDefinedIterator(
123848
123978
  fileInfos.keys(),
@@ -123853,7 +123983,7 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123853
123983
  if (isNumber(value)) semanticDiagnostics.delete(toFilePath(value));
123854
123984
  else semanticDiagnostics.set(toFilePath(value[0]), value[1]);
123855
123985
  });
123856
- return semanticDiagnostics.size ? semanticDiagnostics : void 0;
123986
+ return semanticDiagnostics;
123857
123987
  }
123858
123988
  function toPerFileEmitDiagnostics(diagnostics) {
123859
123989
  return diagnostics && arrayToMap(diagnostics, (value) => toFilePath(value[0]), (value) => value[1]);
@@ -126969,8 +127099,6 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
126969
127099
  ({ buildResult, step } = buildErrors(
126970
127100
  state,
126971
127101
  projectPath,
126972
- program,
126973
- config,
126974
127102
  diagnostics,
126975
127103
  errorFlags,
126976
127104
  errorType
@@ -127033,8 +127161,6 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
127033
127161
  ({ buildResult, step } = buildErrors(
127034
127162
  state,
127035
127163
  projectPath,
127036
- program,
127037
- config,
127038
127164
  declDiagnostics,
127039
127165
  32 /* DeclarationEmitErrors */,
127040
127166
  "Declaration file"
@@ -127097,8 +127223,6 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
127097
127223
  ({ buildResult, step } = buildErrors(
127098
127224
  state,
127099
127225
  projectPath,
127100
- program,
127101
- config,
127102
127226
  emitDiagnostics,
127103
127227
  64 /* EmitErrors */,
127104
127228
  "Emit"
@@ -127278,13 +127402,10 @@ function afterProgramDone(state, program) {
127278
127402
  }
127279
127403
  state.projectCompilerOptions = state.baseCompilerOptions;
127280
127404
  }
127281
- function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
127282
- const canEmitBuildInfo = program && !program.getCompilerOptions().outFile;
127405
+ function buildErrors(state, resolvedPath, diagnostics, buildResult, errorType) {
127283
127406
  reportAndStoreErrors(state, resolvedPath, diagnostics);
127284
127407
  state.projectStatus.set(resolvedPath, { type: 0 /* Unbuildable */, reason: `${errorType} errors` });
127285
- if (canEmitBuildInfo) return { buildResult, step: 4 /* EmitBuildInfo */ };
127286
- afterProgramDone(state, program);
127287
- return { buildResult, step: 5 /* QueueReferencingProjects */ };
127408
+ return { buildResult, step: 4 /* EmitBuildInfo */ };
127288
127409
  }
127289
127410
  function isFileWatcherWithModifiedTime(value) {
127290
127411
  return !!value.watcher;
@@ -127459,7 +127580,7 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127459
127580
  };
127460
127581
  }
127461
127582
  if (buildInfo.program) {
127462
- if (((_a = buildInfo.program.changeFileSet) == null ? void 0 : _a.length) || (!project.options.noEmit ? ((_b = buildInfo.program.affectedFilesPendingEmit) == null ? void 0 : _b.length) || ((_c = buildInfo.program.emitDiagnosticsPerFile) == null ? void 0 : _c.length) : (_d = buildInfo.program.semanticDiagnosticsPerFile) == null ? void 0 : _d.length)) {
127583
+ if (((_a = buildInfo.program.changeFileSet) == null ? void 0 : _a.length) || (!project.options.noEmit ? ((_b = buildInfo.program.affectedFilesPendingEmit) == null ? void 0 : _b.length) || ((_c = buildInfo.program.emitDiagnosticsPerFile) == null ? void 0 : _c.length) || buildInfo.program.pendingEmit !== void 0 : (_d = buildInfo.program.semanticDiagnosticsPerFile) == null ? void 0 : _d.length)) {
127463
127584
  return {
127464
127585
  type: 7 /* OutOfDateBuildInfo */,
127465
127586
  buildInfoFile: buildInfoPath