typescript 5.5.0-dev.20240603 → 5.6.0-dev.20240604

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-dev.20240603`;
20
+ var versionMajorMinor = "5.6";
21
+ var version = `${versionMajorMinor}.0-dev.20240604`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -51544,10 +51544,11 @@ function createTypeChecker(host) {
51544
51544
  return result ? setTextRange2(context, result, node) : void 0;
51545
51545
  }
51546
51546
  function createRecoveryBoundary() {
51547
+ let trackedSymbols;
51547
51548
  let unreportedErrors;
51548
51549
  const oldTracker = context.tracker;
51549
51550
  const oldTrackedSymbols = context.trackedSymbols;
51550
- context.trackedSymbols = [];
51551
+ context.trackedSymbols = void 0;
51551
51552
  const oldEncounteredError = context.encounteredError;
51552
51553
  context.tracker = new SymbolTrackerImpl(context, {
51553
51554
  ...oldTracker.inner,
@@ -51567,17 +51568,7 @@ function createTypeChecker(host) {
51567
51568
  markError(() => oldTracker.reportNonSerializableProperty(name));
51568
51569
  },
51569
51570
  trackSymbol(sym, decl, meaning) {
51570
- const accessibility = isSymbolAccessible(
51571
- sym,
51572
- decl,
51573
- meaning,
51574
- /*shouldComputeAliasesToMakeVisible*/
51575
- false
51576
- );
51577
- if (accessibility.accessibility !== 0 /* Accessible */) {
51578
- (context.trackedSymbols ?? (context.trackedSymbols = [])).push([sym, decl, meaning]);
51579
- return true;
51580
- }
51571
+ (trackedSymbols ?? (trackedSymbols = [])).push([sym, decl, meaning]);
51581
51572
  return false;
51582
51573
  },
51583
51574
  moduleResolverHost: context.tracker.moduleResolverHost
@@ -51591,13 +51582,12 @@ function createTypeChecker(host) {
51591
51582
  (unreportedErrors ?? (unreportedErrors = [])).push(unreportedError);
51592
51583
  }
51593
51584
  function startRecoveryScope2() {
51594
- var _a;
51595
- const initialTrackedSymbolsTop = ((_a = context.trackedSymbols) == null ? void 0 : _a.length) ?? 0;
51585
+ const trackedSymbolsTop = (trackedSymbols == null ? void 0 : trackedSymbols.length) ?? 0;
51596
51586
  const unreportedErrorsTop = (unreportedErrors == null ? void 0 : unreportedErrors.length) ?? 0;
51597
51587
  return () => {
51598
51588
  hadError = false;
51599
- if (context.trackedSymbols) {
51600
- context.trackedSymbols.length = initialTrackedSymbolsTop;
51589
+ if (trackedSymbols) {
51590
+ trackedSymbols.length = trackedSymbolsTop;
51601
51591
  }
51602
51592
  if (unreportedErrors) {
51603
51593
  unreportedErrors.length = unreportedErrorsTop;
@@ -51606,14 +51596,13 @@ function createTypeChecker(host) {
51606
51596
  }
51607
51597
  function finalizeBoundary2() {
51608
51598
  context.tracker = oldTracker;
51609
- const newTrackedSymbols = context.trackedSymbols;
51610
51599
  context.trackedSymbols = oldTrackedSymbols;
51611
51600
  context.encounteredError = oldEncounteredError;
51612
51601
  unreportedErrors == null ? void 0 : unreportedErrors.forEach((fn) => fn());
51613
51602
  if (hadError) {
51614
51603
  return false;
51615
51604
  }
51616
- newTrackedSymbols == null ? void 0 : newTrackedSymbols.forEach(
51605
+ trackedSymbols == null ? void 0 : trackedSymbols.forEach(
51617
51606
  ([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
51618
51607
  symbol,
51619
51608
  enclosingDeclaration,
@@ -51626,6 +51615,57 @@ function createTypeChecker(host) {
51626
51615
  function onEnterNewScope(node) {
51627
51616
  return enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
51628
51617
  }
51618
+ function tryVisitSimpleTypeNode(node) {
51619
+ const innerNode = skipTypeParentheses(node);
51620
+ switch (innerNode.kind) {
51621
+ case 183 /* TypeReference */:
51622
+ return tryVisitTypeReference(innerNode);
51623
+ case 186 /* TypeQuery */:
51624
+ return tryVisitTypeQuery(innerNode);
51625
+ case 199 /* IndexedAccessType */:
51626
+ return tryVisitIndexedAccess(innerNode);
51627
+ case 198 /* TypeOperator */:
51628
+ const typeOperatorNode = innerNode;
51629
+ if (typeOperatorNode.operator === 143 /* KeyOfKeyword */) {
51630
+ return tryVisitKeyOf(typeOperatorNode);
51631
+ }
51632
+ }
51633
+ return visitNode(node, visitExistingNodeTreeSymbols, isTypeNode);
51634
+ }
51635
+ function tryVisitIndexedAccess(node) {
51636
+ const resultObjectType = tryVisitSimpleTypeNode(node.objectType);
51637
+ if (resultObjectType === void 0) {
51638
+ return void 0;
51639
+ }
51640
+ return factory.updateIndexedAccessTypeNode(node, resultObjectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode));
51641
+ }
51642
+ function tryVisitKeyOf(node) {
51643
+ Debug.assertEqual(node.operator, 143 /* KeyOfKeyword */);
51644
+ const type = tryVisitSimpleTypeNode(node.type);
51645
+ if (type === void 0) {
51646
+ return void 0;
51647
+ }
51648
+ return factory.updateTypeOperatorNode(node, type);
51649
+ }
51650
+ function tryVisitTypeQuery(node) {
51651
+ const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
51652
+ if (!introducesError) {
51653
+ return factory.updateTypeQueryNode(
51654
+ node,
51655
+ exprName,
51656
+ visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
51657
+ );
51658
+ }
51659
+ const serializedName = serializeTypeName(
51660
+ context,
51661
+ node.exprName,
51662
+ /*isTypeOf*/
51663
+ true
51664
+ );
51665
+ if (serializedName) {
51666
+ return setTextRange2(context, serializedName, node.exprName);
51667
+ }
51668
+ }
51629
51669
  function tryVisitTypeReference(node) {
51630
51670
  if (canReuseTypeNode(context, node)) {
51631
51671
  const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
@@ -51759,13 +51799,13 @@ function createTypeChecker(host) {
51759
51799
  visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
51760
51800
  );
51761
51801
  }
51762
- if (isIndexedAccessTypeNode(node) && isTypeReferenceNode(node.objectType)) {
51763
- const objectType = tryVisitTypeReference(node.objectType);
51764
- if (!objectType) {
51802
+ if (isIndexedAccessTypeNode(node)) {
51803
+ const result = tryVisitIndexedAccess(node);
51804
+ if (!result) {
51765
51805
  hadError = true;
51766
51806
  return node;
51767
51807
  }
51768
- return factory.updateIndexedAccessTypeNode(node, objectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode));
51808
+ return result;
51769
51809
  }
51770
51810
  if (isTypeReferenceNode(node)) {
51771
51811
  const result = tryVisitTypeReference(node);
@@ -51808,25 +51848,12 @@ function createTypeChecker(host) {
51808
51848
  return visited;
51809
51849
  }
51810
51850
  if (isTypeQueryNode(node)) {
51811
- const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
51812
- if (introducesError) {
51813
- const serializedName = serializeTypeName(
51814
- context,
51815
- node.exprName,
51816
- /*isTypeOf*/
51817
- true
51818
- );
51819
- if (serializedName) {
51820
- return setTextRange2(context, serializedName, node.exprName);
51821
- }
51851
+ const result = tryVisitTypeQuery(node);
51852
+ if (!result) {
51822
51853
  hadError = true;
51823
51854
  return node;
51824
51855
  }
51825
- return factory.updateTypeQueryNode(
51826
- node,
51827
- exprName,
51828
- visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
51829
- );
51856
+ return result;
51830
51857
  }
51831
51858
  if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
51832
51859
  const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
@@ -51891,14 +51918,12 @@ function createTypeChecker(host) {
51891
51918
  return node;
51892
51919
  }
51893
51920
  } else if (node.operator === 143 /* KeyOfKeyword */) {
51894
- if (isTypeReferenceNode(node.type)) {
51895
- const type = tryVisitTypeReference(node.type);
51896
- if (!type) {
51897
- hadError = true;
51898
- return node;
51899
- }
51900
- return factory.updateTypeOperatorNode(node, type);
51921
+ const result = tryVisitKeyOf(node);
51922
+ if (!result) {
51923
+ hadError = true;
51924
+ return node;
51901
51925
  }
51926
+ return result;
51902
51927
  }
51903
51928
  }
51904
51929
  return visitEachChild2(node, visitExistingNodeTreeSymbols);
@@ -112766,16 +112791,16 @@ function isBuildInfoFile(file) {
112766
112791
  function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit = false, onlyBuildInfo, includeBuildInfo) {
112767
112792
  const sourceFiles = isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
112768
112793
  const options = host.getCompilerOptions();
112769
- if (options.outFile) {
112770
- if (sourceFiles.length) {
112771
- const bundle = factory.createBundle(sourceFiles);
112772
- const result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
112773
- if (result) {
112774
- return result;
112794
+ if (!onlyBuildInfo) {
112795
+ if (options.outFile) {
112796
+ if (sourceFiles.length) {
112797
+ const bundle = factory.createBundle(sourceFiles);
112798
+ const result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
112799
+ if (result) {
112800
+ return result;
112801
+ }
112775
112802
  }
112776
- }
112777
- } else {
112778
- if (!onlyBuildInfo) {
112803
+ } else {
112779
112804
  for (const sourceFile of sourceFiles) {
112780
112805
  const result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
112781
112806
  if (result) {
@@ -112783,14 +112808,14 @@ function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDt
112783
112808
  }
112784
112809
  }
112785
112810
  }
112786
- if (includeBuildInfo) {
112787
- const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
112788
- if (buildInfoPath) return action(
112789
- { buildInfoPath },
112790
- /*sourceFileOrBundle*/
112791
- void 0
112792
- );
112793
- }
112811
+ }
112812
+ if (includeBuildInfo) {
112813
+ const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
112814
+ if (buildInfoPath) return action(
112815
+ { buildInfoPath },
112816
+ /*sourceFileOrBundle*/
112817
+ void 0
112818
+ );
112794
112819
  }
112795
112820
  }
112796
112821
  function getTsBuildInfoEmitOutputFilePath(options) {
@@ -112819,8 +112844,7 @@ function getOutputPathsForBundle(options, forceDtsPaths) {
112819
112844
  const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
112820
112845
  const declarationFilePath = forceDtsPaths || getEmitDeclarations(options) ? removeFileExtension(outPath) + ".d.ts" /* Dts */ : void 0;
112821
112846
  const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : void 0;
112822
- const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
112823
- return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath };
112847
+ return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath };
112824
112848
  }
112825
112849
  function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
112826
112850
  const options = host.getCompilerOptions();
@@ -112834,7 +112858,7 @@ function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
112834
112858
  const sourceMapFilePath = !jsFilePath || isJsonSourceFile(sourceFile) ? void 0 : getSourceMapFilePath(jsFilePath, options);
112835
112859
  const declarationFilePath = forceDtsPaths || getEmitDeclarations(options) && !isJsonFile ? getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : void 0;
112836
112860
  const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : void 0;
112837
- return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath: void 0 };
112861
+ return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath };
112838
112862
  }
112839
112863
  }
112840
112864
  function getSourceMapFilePath(jsFilePath, options) {
@@ -112883,7 +112907,7 @@ function createAddOutput() {
112883
112907
  }
112884
112908
  }
112885
112909
  function getSingleOutputFileNames(configFile, addOutput) {
112886
- const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath } = getOutputPathsForBundle(
112910
+ const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath } = getOutputPathsForBundle(
112887
112911
  configFile.options,
112888
112912
  /*forceDtsPaths*/
112889
112913
  false
@@ -112892,7 +112916,6 @@ function getSingleOutputFileNames(configFile, addOutput) {
112892
112916
  addOutput(sourceMapFilePath);
112893
112917
  addOutput(declarationFilePath);
112894
112918
  addOutput(declarationMapPath);
112895
- addOutput(buildInfoPath);
112896
112919
  }
112897
112920
  function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory2) {
112898
112921
  if (isDeclarationFileName(inputFileName)) return;
@@ -112943,8 +112966,8 @@ function getAllProjectOutputs(configFile, ignoreCase) {
112943
112966
  for (const inputFileName of configFile.fileNames) {
112944
112967
  getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory2);
112945
112968
  }
112946
- addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
112947
112969
  }
112970
+ addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
112948
112971
  return getOutputs();
112949
112972
  }
112950
112973
  function getFirstProjectOutput(configFile, ignoreCase) {
@@ -112973,7 +112996,7 @@ function getFirstProjectOutput(configFile, ignoreCase) {
112973
112996
  function emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) {
112974
112997
  return !!forceDtsEmit && !!emitOnly;
112975
112998
  }
112976
- function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, declarationTransformers }, emitOnly, onlyBuildInfo, forceDtsEmit) {
112999
+ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, declarationTransformers }, emitOnly, onlyBuildInfo, forceDtsEmit, skipBuildInfo) {
112977
113000
  var compilerOptions = host.getCompilerOptions();
112978
113001
  var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap || getAreDeclarationMapsEnabled(compilerOptions) ? [] : void 0;
112979
113002
  var emittedFilesList = compilerOptions.listEmittedFiles ? [] : void 0;
@@ -112989,7 +113012,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
112989
113012
  getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit),
112990
113013
  forceDtsEmit,
112991
113014
  onlyBuildInfo,
112992
- !targetSourceFile
113015
+ !targetSourceFile && !skipBuildInfo
112993
113016
  );
112994
113017
  exit();
112995
113018
  return {
@@ -113011,7 +113034,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113011
113034
  (_f = tracing) == null ? void 0 : _f.pop();
113012
113035
  }
113013
113036
  function emitBuildInfo(buildInfoPath) {
113014
- if (!buildInfoPath || targetSourceFile || emitSkipped) return;
113037
+ if (!buildInfoPath || targetSourceFile) return;
113015
113038
  if (host.isEmitBlocked(buildInfoPath)) {
113016
113039
  emitSkipped = true;
113017
113040
  return;
@@ -119964,7 +119987,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119964
119987
  }
119965
119988
  function emitBuildInfo(writeFileCallback) {
119966
119989
  var _a2, _b2;
119967
- Debug.assert(!options.outFile);
119968
119990
  (_a2 = tracing) == null ? void 0 : _a2.push(
119969
119991
  tracing.Phase.Emit,
119970
119992
  "emitBuildInfo",
@@ -120019,7 +120041,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120019
120041
  function getTypeChecker() {
120020
120042
  return typeChecker || (typeChecker = createTypeChecker(program));
120021
120043
  }
120022
- function emit(sourceFile, writeFileCallback, cancellationToken, emitOnly, transformers, forceDtsEmit) {
120044
+ function emit(sourceFile, writeFileCallback, cancellationToken, emitOnly, transformers, forceDtsEmit, skipBuildInfo) {
120023
120045
  var _a2, _b2;
120024
120046
  (_a2 = tracing) == null ? void 0 : _a2.push(
120025
120047
  tracing.Phase.Emit,
@@ -120028,14 +120050,25 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120028
120050
  /*separateBeginAndEnd*/
120029
120051
  true
120030
120052
  );
120031
- const result = runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnly, transformers, forceDtsEmit));
120053
+ const result = runWithCancellationToken(
120054
+ () => emitWorker(
120055
+ program,
120056
+ sourceFile,
120057
+ writeFileCallback,
120058
+ cancellationToken,
120059
+ emitOnly,
120060
+ transformers,
120061
+ forceDtsEmit,
120062
+ skipBuildInfo
120063
+ )
120064
+ );
120032
120065
  (_b2 = tracing) == null ? void 0 : _b2.pop();
120033
120066
  return result;
120034
120067
  }
120035
120068
  function isEmitBlocked(emitFileName) {
120036
120069
  return hasEmitBlockingDiagnostics.has(toPath3(emitFileName));
120037
120070
  }
120038
- function emitWorker(program2, sourceFile, writeFileCallback, cancellationToken, emitOnly, customTransformers, forceDtsEmit) {
120071
+ function emitWorker(program2, sourceFile, writeFileCallback, cancellationToken, emitOnly, customTransformers, forceDtsEmit, skipBuildInfo) {
120039
120072
  if (!forceDtsEmit) {
120040
120073
  const result = handleNoEmitOptions(program2, sourceFile, writeFileCallback, cancellationToken);
120041
120074
  if (result) return result;
@@ -120057,7 +120090,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120057
120090
  emitOnly,
120058
120091
  /*onlyBuildInfo*/
120059
120092
  false,
120060
- forceDtsEmit
120093
+ forceDtsEmit,
120094
+ skipBuildInfo
120061
120095
  )
120062
120096
  );
120063
120097
  mark("afterEmit");
@@ -122189,7 +122223,7 @@ function handleNoEmitOptions(program, sourceFile, writeFile2, cancellationToken)
122189
122223
  const options = program.getCompilerOptions();
122190
122224
  if (options.noEmit) {
122191
122225
  program.getSemanticDiagnostics(sourceFile, cancellationToken);
122192
- return sourceFile || options.outFile ? emitSkippedWithNoDiagnostics : program.emitBuildInfo(writeFile2, cancellationToken);
122226
+ return sourceFile ? emitSkippedWithNoDiagnostics : program.emitBuildInfo(writeFile2, cancellationToken);
122193
122227
  }
122194
122228
  if (!options.noEmitOnError) return void 0;
122195
122229
  let diagnostics = [
@@ -122207,7 +122241,7 @@ function handleNoEmitOptions(program, sourceFile, writeFile2, cancellationToken)
122207
122241
  }
122208
122242
  if (!diagnostics.length) return void 0;
122209
122243
  let emittedFiles;
122210
- if (!sourceFile && !options.outFile) {
122244
+ if (!sourceFile) {
122211
122245
  const emitResult = program.emitBuildInfo(writeFile2, cancellationToken);
122212
122246
  if (emitResult.diagnostics) diagnostics = [...diagnostics, ...emitResult.diagnostics];
122213
122247
  emittedFiles = emitResult.emittedFiles;
@@ -122689,17 +122723,17 @@ function createBuilderProgramState(newProgram, oldState) {
122689
122723
  const compilerOptions = newProgram.getCompilerOptions();
122690
122724
  state.compilerOptions = compilerOptions;
122691
122725
  const outFilePath = compilerOptions.outFile;
122692
- if (!outFilePath) {
122693
- state.semanticDiagnosticsPerFile = /* @__PURE__ */ new Map();
122694
- } else if (compilerOptions.composite && (oldState == null ? void 0 : oldState.outSignature) && outFilePath === oldState.compilerOptions.outFile) {
122726
+ state.semanticDiagnosticsPerFile = /* @__PURE__ */ new Map();
122727
+ if (outFilePath && compilerOptions.composite && (oldState == null ? void 0 : oldState.outSignature) && outFilePath === oldState.compilerOptions.outFile) {
122695
122728
  state.outSignature = oldState.outSignature && getEmitSignatureFromOldSignature(compilerOptions, oldState.compilerOptions, oldState.outSignature);
122696
122729
  }
122697
122730
  state.changedFilesSet = /* @__PURE__ */ new Set();
122698
122731
  state.latestChangedDtsFile = compilerOptions.composite ? oldState == null ? void 0 : oldState.latestChangedDtsFile : void 0;
122699
122732
  const useOldState = BuilderState.canReuseOldState(state.referencedMap, oldState);
122700
122733
  const oldCompilerOptions = useOldState ? oldState.compilerOptions : void 0;
122701
- const canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && !compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122734
+ let canCopySemanticDiagnostics = useOldState && !compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122702
122735
  const canCopyEmitSignatures = compilerOptions.composite && (oldState == null ? void 0 : oldState.emitSignatures) && !outFilePath && !compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
122736
+ let canCopyEmitDiagnostics = true;
122703
122737
  if (useOldState) {
122704
122738
  (_a = oldState.changedFilesSet) == null ? void 0 : _a.forEach((value) => state.changedFilesSet.add(value));
122705
122739
  if (!outFilePath && ((_b = oldState.affectedFilesPendingEmit) == null ? void 0 : _b.size)) {
@@ -122707,6 +122741,10 @@ function createBuilderProgramState(newProgram, oldState) {
122707
122741
  state.seenAffectedFiles = /* @__PURE__ */ new Set();
122708
122742
  }
122709
122743
  state.programEmitPending = oldState.programEmitPending;
122744
+ if (outFilePath && state.changedFilesSet.size) {
122745
+ canCopySemanticDiagnostics = false;
122746
+ canCopyEmitDiagnostics = false;
122747
+ }
122710
122748
  } else {
122711
122749
  state.buildInfoEmitPending = true;
122712
122750
  }
@@ -122724,10 +122762,10 @@ function createBuilderProgramState(newProgram, oldState) {
122724
122762
  oldInfo.impliedFormat !== info.impliedFormat || // Referenced files changed
122725
122763
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) || // Referenced file was deleted in the new program
122726
122764
  newReferences && forEachKey(newReferences, (path) => !state.fileInfos.has(path) && oldState.fileInfos.has(path))) {
122727
- addFileToChangeSet(state, sourceFilePath);
122765
+ addFileToChangeSet(sourceFilePath);
122728
122766
  } else {
122729
122767
  const sourceFile = newProgram.getSourceFileByPath(sourceFilePath);
122730
- const emitDiagnostics = (_a2 = oldState.emitDiagnosticsPerFile) == null ? void 0 : _a2.get(sourceFilePath);
122768
+ const emitDiagnostics = canCopyEmitDiagnostics ? (_a2 = oldState.emitDiagnosticsPerFile) == null ? void 0 : _a2.get(sourceFilePath) : void 0;
122731
122769
  if (emitDiagnostics) {
122732
122770
  (state.emitDiagnosticsPerFile ?? (state.emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(
122733
122771
  sourceFilePath,
@@ -122756,16 +122794,16 @@ function createBuilderProgramState(newProgram, oldState) {
122756
122794
  });
122757
122795
  if (useOldState && forEachEntry(oldState.fileInfos, (info, sourceFilePath) => {
122758
122796
  if (state.fileInfos.has(sourceFilePath)) return false;
122759
- if (outFilePath || info.affectsGlobalScope) return true;
122797
+ if (info.affectsGlobalScope) return true;
122760
122798
  state.buildInfoEmitPending = true;
122761
- return false;
122799
+ return !!outFilePath;
122762
122800
  })) {
122763
122801
  BuilderState.getAllFilesExcludingDefaultLibraryFile(
122764
122802
  state,
122765
122803
  newProgram,
122766
122804
  /*firstSourceFile*/
122767
122805
  void 0
122768
- ).forEach((file) => addFileToChangeSet(state, file.resolvedPath));
122806
+ ).forEach((file) => addFileToChangeSet(file.resolvedPath));
122769
122807
  } else if (oldCompilerOptions) {
122770
122808
  const pendingEmitKind = compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions) ? getBuilderFileEmit(compilerOptions) : getPendingEmitKind(compilerOptions, oldCompilerOptions);
122771
122809
  if (pendingEmitKind !== 0 /* None */) {
@@ -122781,18 +122819,25 @@ function createBuilderProgramState(newProgram, oldState) {
122781
122819
  });
122782
122820
  Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
122783
122821
  state.seenAffectedFiles = state.seenAffectedFiles || /* @__PURE__ */ new Set();
122784
- state.buildInfoEmitPending = true;
122785
- } else {
122822
+ } else if (!state.changedFilesSet.size) {
122786
122823
  state.programEmitPending = state.programEmitPending ? state.programEmitPending | pendingEmitKind : pendingEmitKind;
122787
122824
  }
122825
+ state.buildInfoEmitPending = true;
122788
122826
  }
122789
122827
  }
122790
122828
  return state;
122791
- }
122792
- function addFileToChangeSet(state, path) {
122793
- state.changedFilesSet.add(path);
122794
- state.buildInfoEmitPending = true;
122795
- state.programEmitPending = void 0;
122829
+ function addFileToChangeSet(path) {
122830
+ state.changedFilesSet.add(path);
122831
+ if (outFilePath) {
122832
+ canCopySemanticDiagnostics = false;
122833
+ canCopyEmitDiagnostics = false;
122834
+ state.semanticDiagnosticsFromOldState = void 0;
122835
+ state.semanticDiagnosticsPerFile.clear();
122836
+ state.emitDiagnosticsPerFile = void 0;
122837
+ }
122838
+ state.buildInfoEmitPending = true;
122839
+ state.programEmitPending = void 0;
122840
+ }
122796
122841
  }
122797
122842
  function getEmitSignatureFromOldSignature(options, oldOptions, oldEmitSignature) {
122798
122843
  return !!options.declarationMap === !!oldOptions.declarationMap ? (
@@ -122865,6 +122910,7 @@ function backupBuilderProgramEmitState(state) {
122865
122910
  return {
122866
122911
  affectedFilesPendingEmit: state.affectedFilesPendingEmit && new Map(state.affectedFilesPendingEmit),
122867
122912
  seenEmittedFiles: state.seenEmittedFiles && new Map(state.seenEmittedFiles),
122913
+ seenProgramEmit: state.seenProgramEmit,
122868
122914
  programEmitPending: state.programEmitPending,
122869
122915
  emitSignatures: state.emitSignatures && new Map(state.emitSignatures),
122870
122916
  outSignature: state.outSignature,
@@ -122878,6 +122924,7 @@ function backupBuilderProgramEmitState(state) {
122878
122924
  function restoreBuilderProgramEmitState(state, savedEmitState) {
122879
122925
  state.affectedFilesPendingEmit = savedEmitState.affectedFilesPendingEmit;
122880
122926
  state.seenEmittedFiles = savedEmitState.seenEmittedFiles;
122927
+ state.seenProgramEmit = savedEmitState.seenProgramEmit;
122881
122928
  state.programEmitPending = savedEmitState.programEmitPending;
122882
122929
  state.emitSignatures = savedEmitState.emitSignatures;
122883
122930
  state.outSignature = savedEmitState.outSignature;
@@ -122886,6 +122933,10 @@ function restoreBuilderProgramEmitState(state, savedEmitState) {
122886
122933
  state.buildInfoEmitPending = savedEmitState.buildInfoEmitPending;
122887
122934
  state.emitDiagnosticsPerFile = savedEmitState.emitDiagnosticsPerFile;
122888
122935
  if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet;
122936
+ if (state.compilerOptions.outFile && state.changedFilesSet.size) {
122937
+ state.semanticDiagnosticsPerFile.clear();
122938
+ state.emitDiagnosticsPerFile = void 0;
122939
+ }
122889
122940
  }
122890
122941
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
122891
122942
  Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
@@ -122923,10 +122974,7 @@ function getNextAffectedFile(state, cancellationToken, host) {
122923
122974
  }
122924
122975
  const program = Debug.checkDefined(state.program);
122925
122976
  const compilerOptions = program.getCompilerOptions();
122926
- if (compilerOptions.outFile) {
122927
- Debug.assert(!state.semanticDiagnosticsPerFile);
122928
- return program;
122929
- }
122977
+ if (compilerOptions.outFile) return program;
122930
122978
  state.affectedFiles = BuilderState.getFilesAffectedByWithOldState(
122931
122979
  state,
122932
122980
  program,
@@ -122940,14 +122988,22 @@ function getNextAffectedFile(state, cancellationToken, host) {
122940
122988
  }
122941
122989
  }
122942
122990
  function clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles) {
122943
- var _a;
122944
- if (!((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size)) return;
122945
- if (!emitOnlyDtsFiles) return state.affectedFilesPendingEmit = void 0;
122946
- state.affectedFilesPendingEmit.forEach((emitKind, path) => {
122991
+ var _a, _b;
122992
+ if (!((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size) && !state.programEmitPending) return;
122993
+ if (!emitOnlyDtsFiles) {
122994
+ state.affectedFilesPendingEmit = void 0;
122995
+ state.programEmitPending = void 0;
122996
+ }
122997
+ (_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.forEach((emitKind, path) => {
122947
122998
  const pending = emitKind & 7 /* AllJs */;
122948
122999
  if (!pending) state.affectedFilesPendingEmit.delete(path);
122949
123000
  else state.affectedFilesPendingEmit.set(path, pending);
122950
123001
  });
123002
+ if (state.programEmitPending) {
123003
+ const pending = state.programEmitPending & 7 /* AllJs */;
123004
+ if (!pending) state.programEmitPending = void 0;
123005
+ else state.programEmitPending = pending;
123006
+ }
122951
123007
  }
122952
123008
  function getNextAffectedFilePendingEmit(state, emitOnlyDtsFiles) {
122953
123009
  var _a;
@@ -123139,24 +123195,21 @@ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, invalidateJsF
123139
123195
  );
123140
123196
  return void 0;
123141
123197
  }
123142
- function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
123198
+ function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
123143
123199
  return concatenate(
123144
- getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken),
123200
+ getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile),
123145
123201
  Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile)
123146
123202
  );
123147
123203
  }
123148
- function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken) {
123204
+ function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken, semanticDiagnosticsPerFile) {
123205
+ semanticDiagnosticsPerFile ?? (semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile);
123149
123206
  const path = sourceFile.resolvedPath;
123150
- if (state.semanticDiagnosticsPerFile) {
123151
- const cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
123152
- if (cachedDiagnostics) {
123153
- return filterSemanticDiagnostics(cachedDiagnostics, state.compilerOptions);
123154
- }
123207
+ const cachedDiagnostics = semanticDiagnosticsPerFile.get(path);
123208
+ if (cachedDiagnostics) {
123209
+ return filterSemanticDiagnostics(cachedDiagnostics, state.compilerOptions);
123155
123210
  }
123156
123211
  const diagnostics = Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
123157
- if (state.semanticDiagnosticsPerFile) {
123158
- state.semanticDiagnosticsPerFile.set(path, diagnostics);
123159
- }
123212
+ semanticDiagnosticsPerFile.set(path, diagnostics);
123160
123213
  return filterSemanticDiagnostics(diagnostics, state.compilerOptions);
123161
123214
  }
123162
123215
  function isProgramBundleEmitBuildInfo(info) {
@@ -123184,6 +123237,9 @@ function getBuildInfo2(state) {
123184
123237
  root,
123185
123238
  resolvedRoot: toResolvedRoot(),
123186
123239
  options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
123240
+ semanticDiagnosticsPerFile: convertToProgramBuildInfoDiagnostics(),
123241
+ emitDiagnosticsPerFile: convertToProgramBuildInfoEmitDiagnostics(),
123242
+ changeFileSet: toChangeFileSet(),
123187
123243
  outSignature: state.outSignature,
123188
123244
  latestChangedDtsFile,
123189
123245
  pendingEmit: !state.programEmitPending ? void 0 : (
@@ -123274,13 +123330,6 @@ function getBuildInfo2(state) {
123274
123330
  }
123275
123331
  }
123276
123332
  }
123277
- let changeFileSet;
123278
- if (state.changedFilesSet.size) {
123279
- for (const path of arrayFrom(state.changedFilesSet.keys()).sort(compareStringsCaseSensitive)) {
123280
- changeFileSet = append(changeFileSet, toFileId(path));
123281
- }
123282
- }
123283
- const emitDiagnosticsPerFile = convertToProgramBuildInfoEmitDiagnostics();
123284
123333
  const program = {
123285
123334
  fileNames,
123286
123335
  fileInfos,
@@ -123290,9 +123339,9 @@ function getBuildInfo2(state) {
123290
123339
  fileIdsList,
123291
123340
  referencedMap,
123292
123341
  semanticDiagnosticsPerFile,
123293
- emitDiagnosticsPerFile,
123342
+ emitDiagnosticsPerFile: convertToProgramBuildInfoEmitDiagnostics(),
123294
123343
  affectedFilesPendingEmit,
123295
- changeFileSet,
123344
+ changeFileSet: toChangeFileSet(),
123296
123345
  emitSignatures,
123297
123346
  latestChangedDtsFile
123298
123347
  };
@@ -123375,8 +123424,7 @@ function getBuildInfo2(state) {
123375
123424
  function convertToProgramBuildInfoDiagnostics() {
123376
123425
  let result;
123377
123426
  state.fileInfos.forEach((_value, key) => {
123378
- var _a2;
123379
- const value = (_a2 = state.semanticDiagnosticsPerFile) == null ? void 0 : _a2.get(key);
123427
+ const value = state.semanticDiagnosticsPerFile.get(key);
123380
123428
  if (!value) {
123381
123429
  if (!state.changedFilesSet.has(key)) result = append(result, toFileId(key));
123382
123430
  } else if (value.length) {
@@ -123445,6 +123493,15 @@ function getBuildInfo2(state) {
123445
123493
  return result;
123446
123494
  }) || array;
123447
123495
  }
123496
+ function toChangeFileSet() {
123497
+ let changeFileSet;
123498
+ if (state.changedFilesSet.size) {
123499
+ for (const path of arrayFrom(state.changedFilesSet.keys()).sort(compareStringsCaseSensitive)) {
123500
+ changeFileSet = append(changeFileSet, toFileId(path));
123501
+ }
123502
+ }
123503
+ return changeFileSet;
123504
+ }
123448
123505
  }
123449
123506
  function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
123450
123507
  let host;
@@ -123543,14 +123600,16 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123543
123600
  return emitSkippedWithNoDiagnostics;
123544
123601
  }
123545
123602
  function emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
123546
- var _a, _b, _c;
123603
+ var _a, _b, _c, _d;
123547
123604
  let affected = getNextAffectedFile(state, cancellationToken, host);
123548
123605
  const programEmitKind = getBuilderFileEmit(state.compilerOptions);
123549
123606
  let emitKind = emitOnlyDtsFiles ? programEmitKind & 24 /* AllDts */ : programEmitKind;
123550
123607
  if (!affected) {
123551
123608
  if (!state.compilerOptions.outFile) {
123552
123609
  const pendingAffectedFile = getNextAffectedFilePendingEmit(state, emitOnlyDtsFiles);
123553
- if (!pendingAffectedFile) {
123610
+ if (pendingAffectedFile) {
123611
+ ({ affectedFile: affected, emitKind } = pendingAffectedFile);
123612
+ } else {
123554
123613
  const pendingForDiagnostics = getNextPendingEmitDiagnosticsFile(state);
123555
123614
  if (pendingForDiagnostics) {
123556
123615
  (state.seenEmittedFiles ?? (state.seenEmittedFiles = /* @__PURE__ */ new Map())).set(pendingForDiagnostics.affectedFile.resolvedPath, pendingForDiagnostics.seenKind | 24 /* AllDts */);
@@ -123559,48 +123618,73 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123559
123618
  affected: pendingForDiagnostics.affectedFile
123560
123619
  };
123561
123620
  }
123562
- if (!state.buildInfoEmitPending) return void 0;
123563
- const affected2 = state.program;
123564
- const result2 = affected2.emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
123565
- state.buildInfoEmitPending = false;
123566
- return { result: result2, affected: affected2 };
123567
123621
  }
123568
- ({ affectedFile: affected, emitKind } = pendingAffectedFile);
123569
123622
  } else {
123570
- if (!state.programEmitPending) return void 0;
123571
- emitKind = state.programEmitPending;
123572
- if (emitOnlyDtsFiles) emitKind = emitKind & 24 /* AllDts */;
123573
- if (!emitKind) return void 0;
123574
- affected = state.program;
123623
+ if (state.programEmitPending) {
123624
+ emitKind = state.programEmitPending;
123625
+ if (emitOnlyDtsFiles) emitKind = emitKind & 24 /* AllDts */;
123626
+ if (emitKind) affected = state.program;
123627
+ }
123628
+ if (!affected && ((_a = state.emitDiagnosticsPerFile) == null ? void 0 : _a.size)) {
123629
+ const seenKind = state.seenProgramEmit || 0 /* None */;
123630
+ if (!(seenKind & 24 /* AllDts */)) {
123631
+ state.seenProgramEmit = 24 /* AllDts */ | seenKind;
123632
+ const diagnostics = [];
123633
+ state.emitDiagnosticsPerFile.forEach((d) => addRange(diagnostics, d));
123634
+ return {
123635
+ result: { emitSkipped: true, diagnostics },
123636
+ affected: state.program
123637
+ };
123638
+ }
123639
+ }
123640
+ }
123641
+ if (!affected) {
123642
+ if (!state.buildInfoEmitPending) return void 0;
123643
+ const affected2 = state.program;
123644
+ const result2 = affected2.emitBuildInfo(writeFile2 || maybeBind(host, host.writeFile), cancellationToken);
123645
+ state.buildInfoEmitPending = false;
123646
+ return { result: result2, affected: affected2 };
123575
123647
  }
123576
123648
  }
123577
123649
  let emitOnly;
123578
123650
  if (emitKind & 7 /* AllJs */) emitOnly = 0 /* Js */;
123579
123651
  if (emitKind & 24 /* AllDts */) emitOnly = emitOnly === void 0 ? 1 /* Dts */ : void 0;
123580
- if (affected === state.program) {
123581
- state.programEmitPending = state.changedFilesSet.size ? getPendingEmitKind(programEmitKind, emitKind) : state.programEmitPending ? getPendingEmitKind(state.programEmitPending, emitKind) : void 0;
123582
- }
123583
123652
  const result = state.program.emit(
123584
123653
  affected === state.program ? void 0 : affected,
123585
123654
  getWriteFileCallback(writeFile2, customTransformers),
123586
123655
  cancellationToken,
123587
123656
  emitOnly,
123588
- customTransformers
123657
+ customTransformers,
123658
+ /*forceDtsEmit*/
123659
+ void 0,
123660
+ /*skipBuildInfo*/
123661
+ true
123589
123662
  );
123590
123663
  if (affected !== state.program) {
123591
123664
  const affectedSourceFile = affected;
123592
123665
  state.seenAffectedFiles.add(affectedSourceFile.resolvedPath);
123593
123666
  if (state.affectedFilesIndex !== void 0) state.affectedFilesIndex++;
123594
123667
  state.buildInfoEmitPending = true;
123595
- const existing = ((_a = state.seenEmittedFiles) == null ? void 0 : _a.get(affectedSourceFile.resolvedPath)) || 0 /* None */;
123668
+ const existing = ((_b = state.seenEmittedFiles) == null ? void 0 : _b.get(affectedSourceFile.resolvedPath)) || 0 /* None */;
123596
123669
  (state.seenEmittedFiles ?? (state.seenEmittedFiles = /* @__PURE__ */ new Map())).set(affectedSourceFile.resolvedPath, emitKind | existing);
123597
- const existingPending = ((_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.get(affectedSourceFile.resolvedPath)) || programEmitKind;
123670
+ const existingPending = ((_c = state.affectedFilesPendingEmit) == null ? void 0 : _c.get(affectedSourceFile.resolvedPath)) || programEmitKind;
123598
123671
  const pendingKind = getPendingEmitKind(existingPending, emitKind | existing);
123599
123672
  if (pendingKind) (state.affectedFilesPendingEmit ?? (state.affectedFilesPendingEmit = /* @__PURE__ */ new Map())).set(affectedSourceFile.resolvedPath, pendingKind);
123600
- else (_c = state.affectedFilesPendingEmit) == null ? void 0 : _c.delete(affectedSourceFile.resolvedPath);
123673
+ else (_d = state.affectedFilesPendingEmit) == null ? void 0 : _d.delete(affectedSourceFile.resolvedPath);
123601
123674
  if (result.diagnostics.length) (state.emitDiagnosticsPerFile ?? (state.emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(affectedSourceFile.resolvedPath, result.diagnostics);
123602
123675
  } else {
123603
123676
  state.changedFilesSet.clear();
123677
+ state.programEmitPending = state.changedFilesSet.size ? getPendingEmitKind(programEmitKind, emitKind) : state.programEmitPending ? getPendingEmitKind(state.programEmitPending, emitKind) : void 0;
123678
+ state.seenProgramEmit = emitKind | (state.seenProgramEmit || 0 /* None */);
123679
+ let emitDiagnosticsPerFile;
123680
+ result.diagnostics.forEach((d) => {
123681
+ if (!d.file) return;
123682
+ let diagnostics = emitDiagnosticsPerFile == null ? void 0 : emitDiagnosticsPerFile.get(d.file.resolvedPath);
123683
+ if (!diagnostics) (emitDiagnosticsPerFile ?? (emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(d.file.resolvedPath, diagnostics = []);
123684
+ diagnostics.push(d);
123685
+ });
123686
+ if (emitDiagnosticsPerFile) state.emitDiagnosticsPerFile = emitDiagnosticsPerFile;
123687
+ state.buildInfoEmitPending = true;
123604
123688
  }
123605
123689
  return { result, affected };
123606
123690
  }
@@ -123722,28 +123806,37 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123722
123806
  state.buildInfoEmitPending = true;
123723
123807
  if (!result) continue;
123724
123808
  } else {
123725
- result = state.program.getSemanticDiagnostics(
123726
- /*sourceFile*/
123727
- void 0,
123728
- cancellationToken
123809
+ let diagnostics;
123810
+ const semanticDiagnosticsPerFile = /* @__PURE__ */ new Map();
123811
+ state.program.getSourceFiles().forEach(
123812
+ (sourceFile) => diagnostics = addRange(
123813
+ diagnostics,
123814
+ getSemanticDiagnosticsOfFile(
123815
+ state,
123816
+ sourceFile,
123817
+ cancellationToken,
123818
+ semanticDiagnosticsPerFile
123819
+ )
123820
+ )
123729
123821
  );
123822
+ state.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
123823
+ result = diagnostics || emptyArray;
123730
123824
  state.changedFilesSet.clear();
123731
123825
  state.programEmitPending = getBuilderFileEmit(state.compilerOptions);
123826
+ state.buildInfoEmitPending = true;
123732
123827
  }
123733
123828
  return { result, affected };
123734
123829
  }
123735
123830
  }
123736
123831
  function getSemanticDiagnostics(sourceFile, cancellationToken) {
123737
123832
  assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
123738
- const compilerOptions = Debug.checkDefined(state.program).getCompilerOptions();
123739
- if (compilerOptions.outFile) {
123740
- Debug.assert(!state.semanticDiagnosticsPerFile);
123741
- return Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
123742
- }
123743
123833
  if (sourceFile) {
123744
123834
  return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
123745
123835
  }
123746
- while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
123836
+ while (true) {
123837
+ const affectedResult = getSemanticDiagnosticsOfNextAffectedFile(cancellationToken);
123838
+ if (!affectedResult) break;
123839
+ if (affectedResult.affected === state.program) return affectedResult.result;
123747
123840
  }
123748
123841
  let diagnostics;
123749
123842
  for (const sourceFile2 of Debug.checkDefined(state.program).getSourceFiles()) {
@@ -123776,8 +123869,9 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123776
123869
  const filePaths = (_a = program.fileNames) == null ? void 0 : _a.map(toPathInBuildInfoDirectory);
123777
123870
  let filePathsSetList;
123778
123871
  const latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : void 0;
123872
+ const fileInfos = /* @__PURE__ */ new Map();
123873
+ const changedFilesSet = new Set(map(program.changeFileSet, toFilePath));
123779
123874
  if (isProgramBundleEmitBuildInfo(program)) {
123780
- const fileInfos = /* @__PURE__ */ new Map();
123781
123875
  program.fileInfos.forEach((fileInfo, index) => {
123782
123876
  const path = toFilePath(index + 1);
123783
123877
  fileInfos.set(path, isString(fileInfo) ? { version: fileInfo, signature: void 0, affectsGlobalScope: void 0, impliedFormat: void 0 } : fileInfo);
@@ -123785,13 +123879,16 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123785
123879
  state = {
123786
123880
  fileInfos,
123787
123881
  compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
123882
+ semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile),
123883
+ emitDiagnosticsPerFile: toPerFileEmitDiagnostics(program.emitDiagnosticsPerFile),
123884
+ hasReusableDiagnostic: true,
123885
+ changedFilesSet,
123788
123886
  latestChangedDtsFile,
123789
123887
  outSignature: program.outSignature,
123790
123888
  programEmitPending: program.pendingEmit === void 0 ? void 0 : toProgramEmitPending(program.pendingEmit, program.options)
123791
123889
  };
123792
123890
  } else {
123793
123891
  filePathsSetList = (_b = program.fileIdsList) == null ? void 0 : _b.map((fileIds) => new Set(fileIds.map(toFilePath)));
123794
- const fileInfos = /* @__PURE__ */ new Map();
123795
123892
  const emitSignatures = ((_c = program.options) == null ? void 0 : _c.composite) && !program.options.outFile ? /* @__PURE__ */ new Map() : void 0;
123796
123893
  program.fileInfos.forEach((fileInfo, index) => {
123797
123894
  const path = toFilePath(index + 1);
@@ -123812,13 +123909,12 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123812
123909
  );
123813
123910
  }
123814
123911
  });
123815
- const changedFilesSet = new Set(map(program.changeFileSet, toFilePath));
123816
123912
  const fullEmitForOptions = program.affectedFilesPendingEmit ? getBuilderFileEmit(program.options || {}) : void 0;
123817
123913
  state = {
123818
123914
  fileInfos,
123819
123915
  compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
123820
123916
  referencedMap: toManyToManyPathMap(program.referencedMap, program.options ?? {}),
123821
- semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile, fileInfos, changedFilesSet),
123917
+ semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile),
123822
123918
  emitDiagnosticsPerFile: toPerFileEmitDiagnostics(program.emitDiagnosticsPerFile),
123823
123919
  hasReusableDiagnostic: true,
123824
123920
  affectedFilesPendingEmit: program.affectedFilesPendingEmit && arrayToMap(program.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
@@ -123870,7 +123966,7 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123870
123966
  referenceMap.forEach(([fileId, fileIdListId]) => map2.set(toFilePath(fileId), toFilePathsSet(fileIdListId)));
123871
123967
  return map2;
123872
123968
  }
123873
- function toPerFileSemanticDiagnostics(diagnostics, fileInfos, changedFilesSet) {
123969
+ function toPerFileSemanticDiagnostics(diagnostics) {
123874
123970
  const semanticDiagnostics = new Map(
123875
123971
  mapDefinedIterator(
123876
123972
  fileInfos.keys(),
@@ -123881,7 +123977,7 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123881
123977
  if (isNumber(value)) semanticDiagnostics.delete(toFilePath(value));
123882
123978
  else semanticDiagnostics.set(toFilePath(value[0]), value[1]);
123883
123979
  });
123884
- return semanticDiagnostics.size ? semanticDiagnostics : void 0;
123980
+ return semanticDiagnostics;
123885
123981
  }
123886
123982
  function toPerFileEmitDiagnostics(diagnostics) {
123887
123983
  return diagnostics && arrayToMap(diagnostics, (value) => toFilePath(value[0]), (value) => value[1]);
@@ -126997,8 +127093,6 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
126997
127093
  ({ buildResult, step } = buildErrors(
126998
127094
  state,
126999
127095
  projectPath,
127000
- program,
127001
- config,
127002
127096
  diagnostics,
127003
127097
  errorFlags,
127004
127098
  errorType
@@ -127061,8 +127155,6 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
127061
127155
  ({ buildResult, step } = buildErrors(
127062
127156
  state,
127063
127157
  projectPath,
127064
- program,
127065
- config,
127066
127158
  declDiagnostics,
127067
127159
  32 /* DeclarationEmitErrors */,
127068
127160
  "Declaration file"
@@ -127125,8 +127217,6 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
127125
127217
  ({ buildResult, step } = buildErrors(
127126
127218
  state,
127127
127219
  projectPath,
127128
- program,
127129
- config,
127130
127220
  emitDiagnostics,
127131
127221
  64 /* EmitErrors */,
127132
127222
  "Emit"
@@ -127306,13 +127396,10 @@ function afterProgramDone(state, program) {
127306
127396
  }
127307
127397
  state.projectCompilerOptions = state.baseCompilerOptions;
127308
127398
  }
127309
- function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
127310
- const canEmitBuildInfo = program && !program.getCompilerOptions().outFile;
127399
+ function buildErrors(state, resolvedPath, diagnostics, buildResult, errorType) {
127311
127400
  reportAndStoreErrors(state, resolvedPath, diagnostics);
127312
127401
  state.projectStatus.set(resolvedPath, { type: 0 /* Unbuildable */, reason: `${errorType} errors` });
127313
- if (canEmitBuildInfo) return { buildResult, step: 4 /* EmitBuildInfo */ };
127314
- afterProgramDone(state, program);
127315
- return { buildResult, step: 5 /* QueueReferencingProjects */ };
127402
+ return { buildResult, step: 4 /* EmitBuildInfo */ };
127316
127403
  }
127317
127404
  function isFileWatcherWithModifiedTime(value) {
127318
127405
  return !!value.watcher;
@@ -127487,7 +127574,7 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127487
127574
  };
127488
127575
  }
127489
127576
  if (buildInfo.program) {
127490
- 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)) {
127577
+ 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)) {
127491
127578
  return {
127492
127579
  type: 7 /* OutOfDateBuildInfo */,
127493
127580
  buildInfoFile: buildInfoPath