typescript 5.6.0-dev.20240628 → 5.6.0-dev.20240629

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/tsc.js +207 -94
  2. package/lib/typescript.js +219 -103
  3. package/package.json +2 -2
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.6";
21
- var version = `${versionMajorMinor}.0-dev.20240628`;
21
+ var version = `${versionMajorMinor}.0-dev.20240629`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -16143,11 +16143,11 @@ function getOwnEmitOutputFilePath(fileName, host, extension) {
16143
16143
  return emitOutputFilePathWithoutExtension + extension;
16144
16144
  }
16145
16145
  function getDeclarationEmitOutputFilePath(fileName, host) {
16146
- return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), (f) => host.getCanonicalFileName(f));
16146
+ return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host);
16147
16147
  }
16148
- function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
16148
+ function getDeclarationEmitOutputFilePathWorker(fileName, options, host) {
16149
16149
  const outputDir = options.declarationDir || options.outDir;
16150
- const path = outputDir ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName) : fileName;
16150
+ const path = outputDir ? getSourceFilePathInNewDirWorker(fileName, outputDir, host.getCurrentDirectory(), host.getCommonSourceDirectory(), (f) => host.getCanonicalFileName(f)) : fileName;
16151
16151
  const declarationExtension = getDeclarationEmitExtensionForPath(path);
16152
16152
  return removeFileExtension(path) + declarationExtension;
16153
16153
  }
@@ -110898,17 +110898,16 @@ function createGetIsolatedDeclarationErrors(resolver) {
110898
110898
  function getDeclarationDiagnostics(host, resolver, file) {
110899
110899
  const compilerOptions = host.getCompilerOptions();
110900
110900
  const files = filter(getSourceFilesToEmit(host, file), isSourceFileNotJson);
110901
- const result = transformNodes(
110901
+ return contains(files, file) ? transformNodes(
110902
110902
  resolver,
110903
110903
  host,
110904
110904
  factory,
110905
110905
  compilerOptions,
110906
- file ? contains(files, file) ? [file] : emptyArray : files,
110906
+ [file],
110907
110907
  [transformDeclarations],
110908
110908
  /*allowDtsFiles*/
110909
110909
  false
110910
- );
110911
- return result.diagnostics;
110910
+ ).diagnostics : void 0;
110912
110911
  }
110913
110912
  var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 1 /* AllowUnresolvedNames */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */;
110914
110913
  function transformDeclarations(context) {
@@ -119211,8 +119210,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119211
119210
  let filesWithReferencesProcessed;
119212
119211
  let fileReasonsToChain;
119213
119212
  let reasonToRelatedInfo;
119214
- const cachedBindAndCheckDiagnosticsForFile = {};
119215
- const cachedDeclarationDiagnosticsForFile = {};
119213
+ let cachedBindAndCheckDiagnosticsForFile;
119214
+ let cachedDeclarationDiagnosticsForFile;
119216
119215
  let fileProcessingDiagnostics;
119217
119216
  let automaticTypeDirectiveNames;
119218
119217
  let automaticTypeDirectiveResolutions;
@@ -120292,8 +120291,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120292
120291
  );
120293
120292
  }
120294
120293
  function getCachedSemanticDiagnostics(sourceFile) {
120295
- var _a2;
120296
- return sourceFile ? (_a2 = cachedBindAndCheckDiagnosticsForFile.perFile) == null ? void 0 : _a2.get(sourceFile.path) : cachedBindAndCheckDiagnosticsForFile.allDiagnostics;
120294
+ return cachedBindAndCheckDiagnosticsForFile == null ? void 0 : cachedBindAndCheckDiagnosticsForFile.get(sourceFile.path);
120297
120295
  }
120298
120296
  function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
120299
120297
  return getBindAndCheckDiagnosticsForFile(
@@ -120315,12 +120313,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120315
120313
  return getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, programDiagnosticsInFile).diagnostics;
120316
120314
  }
120317
120315
  function getDeclarationDiagnostics2(sourceFile, cancellationToken) {
120318
- const options2 = program.getCompilerOptions();
120319
- if (!sourceFile || options2.outFile) {
120320
- return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
120321
- } else {
120322
- return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
120323
- }
120316
+ return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
120324
120317
  }
120325
120318
  function getSyntacticDiagnosticsForFile(sourceFile) {
120326
120319
  if (isSourceFileJS(sourceFile)) {
@@ -120351,7 +120344,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120351
120344
  if (nodesToCheck) {
120352
120345
  return getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken, nodesToCheck);
120353
120346
  }
120354
- return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache);
120347
+ let result = cachedBindAndCheckDiagnosticsForFile == null ? void 0 : cachedBindAndCheckDiagnosticsForFile.get(sourceFile.path);
120348
+ if (!result) {
120349
+ (cachedBindAndCheckDiagnosticsForFile ?? (cachedBindAndCheckDiagnosticsForFile = /* @__PURE__ */ new Map())).set(
120350
+ sourceFile.path,
120351
+ result = getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken)
120352
+ );
120353
+ }
120354
+ return result;
120355
120355
  }
120356
120356
  function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken, nodesToCheck) {
120357
120357
  return runWithCancellationToken(() => {
@@ -120639,7 +120639,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120639
120639
  });
120640
120640
  }
120641
120641
  function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) {
120642
- return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
120642
+ let result = cachedDeclarationDiagnosticsForFile == null ? void 0 : cachedDeclarationDiagnosticsForFile.get(sourceFile.path);
120643
+ if (!result) {
120644
+ (cachedDeclarationDiagnosticsForFile ?? (cachedDeclarationDiagnosticsForFile = /* @__PURE__ */ new Map())).set(
120645
+ sourceFile.path,
120646
+ result = getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken)
120647
+ );
120648
+ }
120649
+ return result;
120643
120650
  }
120644
120651
  function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
120645
120652
  return runWithCancellationToken(() => {
@@ -120647,22 +120654,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120647
120654
  return getDeclarationDiagnostics(getEmitHost(noop), resolver, sourceFile) || emptyArray;
120648
120655
  });
120649
120656
  }
120650
- function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) {
120651
- var _a2;
120652
- const cachedResult = sourceFile ? (_a2 = cache.perFile) == null ? void 0 : _a2.get(sourceFile.path) : cache.allDiagnostics;
120653
- if (cachedResult) {
120654
- return cachedResult;
120655
- }
120656
- const result = getDiagnostics(sourceFile, cancellationToken);
120657
- if (sourceFile) {
120658
- (cache.perFile || (cache.perFile = /* @__PURE__ */ new Map())).set(sourceFile.path, result);
120659
- } else {
120660
- cache.allDiagnostics = result;
120661
- }
120662
- return result;
120663
- }
120664
120657
  function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
120665
- return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
120658
+ return sourceFile.isDeclarationFile ? emptyArray : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
120666
120659
  }
120667
120660
  function getOptionsDiagnostics() {
120668
120661
  return sortAndDeduplicateDiagnostics(concatenate(
@@ -121610,7 +121603,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121610
121603
  if (options.outDir || // there is --outDir specified
121611
121604
  options.rootDir || // there is --rootDir specified
121612
121605
  options.sourceRoot || // there is --sourceRoot specified
121613
- options.mapRoot) {
121606
+ options.mapRoot || // there is --mapRoot specified
121607
+ getEmitDeclarations(options) && options.declarationDir) {
121614
121608
  const dir = getCommonSourceDirectory2();
121615
121609
  if (options.outDir && dir === "" && files.some((file) => getRootLength(file.fileName) > 1)) {
121616
121610
  createDiagnosticForOptionName(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
@@ -121623,14 +121617,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121623
121617
  if (!getEmitDeclarations(options)) {
121624
121618
  createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "emitDeclarationOnly", "declaration", "composite");
121625
121619
  }
121626
- if (options.noEmit) {
121627
- createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
121628
- }
121629
- }
121630
- if (options.noCheck) {
121631
- if (options.noEmit) {
121632
- createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noCheck", "noEmit");
121633
- }
121634
121620
  }
121635
121621
  if (options.emitDecoratorMetadata && !options.experimentalDecorators) {
121636
121622
  createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators");
@@ -122367,7 +122353,6 @@ var emitSkippedWithNoDiagnostics = { diagnostics: emptyArray, sourceMaps: void 0
122367
122353
  function handleNoEmitOptions(program, sourceFile, writeFile2, cancellationToken) {
122368
122354
  const options = program.getCompilerOptions();
122369
122355
  if (options.noEmit) {
122370
- program.getSemanticDiagnostics(sourceFile, cancellationToken);
122371
122356
  return sourceFile ? emitSkippedWithNoDiagnostics : program.emitBuildInfo(writeFile2, cancellationToken);
122372
122357
  }
122373
122358
  if (!options.noEmitOnError) return void 0;
@@ -122844,9 +122829,9 @@ function getBuilderFileEmit(options) {
122844
122829
  let result = 1 /* Js */;
122845
122830
  if (options.sourceMap) result = result | 2 /* JsMap */;
122846
122831
  if (options.inlineSourceMap) result = result | 4 /* JsInlineMap */;
122847
- if (getEmitDeclarations(options)) result = result | 8 /* Dts */;
122848
- if (options.declarationMap) result = result | 16 /* DtsMap */;
122849
- if (options.emitDeclarationOnly) result = result & 24 /* AllDts */;
122832
+ if (getEmitDeclarations(options)) result = result | 24 /* Dts */;
122833
+ if (options.declarationMap) result = result | 32 /* DtsMap */;
122834
+ if (options.emitDeclarationOnly) result = result & 56 /* AllDts */;
122850
122835
  return result;
122851
122836
  }
122852
122837
  function getPendingEmitKind(optionsOrEmitKind, oldOptionsOrEmitKind) {
@@ -122857,7 +122842,8 @@ function getPendingEmitKind(optionsOrEmitKind, oldOptionsOrEmitKind) {
122857
122842
  const diff = oldEmitKind ^ emitKind;
122858
122843
  let result = 0 /* None */;
122859
122844
  if (diff & 7 /* AllJs */) result = emitKind & 7 /* AllJs */;
122860
- if (diff & 24 /* AllDts */) result = result | emitKind & 24 /* AllDts */;
122845
+ if (diff & 8 /* DtsErrors */) result = result | emitKind & 8 /* DtsErrors */;
122846
+ if (diff & 48 /* AllDtsEmit */) result = result | emitKind & 48 /* AllDtsEmit */;
122861
122847
  return result;
122862
122848
  }
122863
122849
  function hasSameKeys(map1, map2) {
@@ -123111,25 +123097,34 @@ function getNextAffectedFile(state, cancellationToken, host) {
123111
123097
  if (!state.seenAffectedFiles) state.seenAffectedFiles = /* @__PURE__ */ new Set();
123112
123098
  }
123113
123099
  }
123114
- function clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles) {
123100
+ function clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles, isForDtsErrors) {
123115
123101
  var _a, _b;
123116
123102
  if (!((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size) && !state.programEmitPending) return;
123117
- if (!emitOnlyDtsFiles) {
123103
+ if (!emitOnlyDtsFiles && !isForDtsErrors) {
123118
123104
  state.affectedFilesPendingEmit = void 0;
123119
123105
  state.programEmitPending = void 0;
123120
123106
  }
123121
123107
  (_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.forEach((emitKind, path) => {
123122
- const pending = emitKind & 7 /* AllJs */;
123108
+ const pending = !isForDtsErrors ? emitKind & 7 /* AllJs */ : emitKind & (7 /* AllJs */ | 48 /* AllDtsEmit */);
123123
123109
  if (!pending) state.affectedFilesPendingEmit.delete(path);
123124
123110
  else state.affectedFilesPendingEmit.set(path, pending);
123125
123111
  });
123126
123112
  if (state.programEmitPending) {
123127
- const pending = state.programEmitPending & 7 /* AllJs */;
123113
+ const pending = !isForDtsErrors ? state.programEmitPending & 7 /* AllJs */ : state.programEmitPending & (7 /* AllJs */ | 48 /* AllDtsEmit */);
123128
123114
  if (!pending) state.programEmitPending = void 0;
123129
123115
  else state.programEmitPending = pending;
123130
123116
  }
123131
123117
  }
123132
- function getNextAffectedFilePendingEmit(state, emitOnlyDtsFiles) {
123118
+ function getPendingEmitKindWithSeen(optionsOrEmitKind, seenOldOptionsOrEmitKind, emitOnlyDtsFiles, isForDtsErrors) {
123119
+ let pendingKind = getPendingEmitKind(optionsOrEmitKind, seenOldOptionsOrEmitKind);
123120
+ if (emitOnlyDtsFiles) pendingKind = pendingKind & 56 /* AllDts */;
123121
+ if (isForDtsErrors) pendingKind = pendingKind & 8 /* DtsErrors */;
123122
+ return pendingKind;
123123
+ }
123124
+ function getBuilderFileEmitAllDts(isForDtsErrors) {
123125
+ return !isForDtsErrors ? 56 /* AllDts */ : 8 /* DtsErrors */;
123126
+ }
123127
+ function getNextAffectedFilePendingEmit(state, emitOnlyDtsFiles, isForDtsErrors) {
123133
123128
  var _a;
123134
123129
  if (!((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size)) return void 0;
123135
123130
  return forEachEntry(state.affectedFilesPendingEmit, (emitKind, path) => {
@@ -123140,12 +123135,16 @@ function getNextAffectedFilePendingEmit(state, emitOnlyDtsFiles) {
123140
123135
  return void 0;
123141
123136
  }
123142
123137
  const seenKind = (_a2 = state.seenEmittedFiles) == null ? void 0 : _a2.get(affectedFile.resolvedPath);
123143
- let pendingKind = getPendingEmitKind(emitKind, seenKind);
123144
- if (emitOnlyDtsFiles) pendingKind = pendingKind & 24 /* AllDts */;
123138
+ const pendingKind = getPendingEmitKindWithSeen(
123139
+ emitKind,
123140
+ seenKind,
123141
+ emitOnlyDtsFiles,
123142
+ isForDtsErrors
123143
+ );
123145
123144
  if (pendingKind) return { affectedFile, emitKind: pendingKind };
123146
123145
  });
123147
123146
  }
123148
- function getNextPendingEmitDiagnosticsFile(state) {
123147
+ function getNextPendingEmitDiagnosticsFile(state, isForDtsErrors) {
123149
123148
  var _a;
123150
123149
  if (!((_a = state.emitDiagnosticsPerFile) == null ? void 0 : _a.size)) return void 0;
123151
123150
  return forEachEntry(state.emitDiagnosticsPerFile, (diagnostics, path) => {
@@ -123156,7 +123155,7 @@ function getNextPendingEmitDiagnosticsFile(state) {
123156
123155
  return void 0;
123157
123156
  }
123158
123157
  const seenKind = ((_a2 = state.seenEmittedFiles) == null ? void 0 : _a2.get(affectedFile.resolvedPath)) || 0 /* None */;
123159
- if (!(seenKind & 24 /* AllDts */)) return { affectedFile, diagnostics, seenKind };
123158
+ if (!(seenKind & getBuilderFileEmitAllDts(isForDtsErrors))) return { affectedFile, diagnostics, seenKind };
123160
123159
  });
123161
123160
  }
123162
123161
  function removeDiagnosticsOfLibraryFiles(state) {
@@ -123211,7 +123210,7 @@ function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken,
123211
123210
  addToAffectedFilesPendingEmit(
123212
123211
  state,
123213
123212
  path,
123214
- state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */
123213
+ state.compilerOptions.declarationMap ? 56 /* AllDts */ : 24 /* Dts */
123215
123214
  );
123216
123215
  }
123217
123216
  }
@@ -123411,8 +123410,9 @@ function getBuildInfo2(state) {
123411
123410
  root,
123412
123411
  resolvedRoot: toResolvedRoot(),
123413
123412
  options: toIncrementalBuildInfoCompilerOptions(state.compilerOptions),
123414
- semanticDiagnosticsPerFile: toIncrementalBuildInfoDiagnostics(),
123413
+ semanticDiagnosticsPerFile: !state.changedFilesSet.size ? toIncrementalBuildInfoDiagnostics() : void 0,
123415
123414
  emitDiagnosticsPerFile: toIncrementalBuildInfoEmitDiagnostics(),
123415
+ changeFileSet: toChangeFileSet(),
123416
123416
  outSignature: state.outSignature,
123417
123417
  latestChangedDtsFile,
123418
123418
  pendingEmit: !state.programEmitPending ? void 0 : (
@@ -123496,7 +123496,7 @@ function getBuildInfo2(state) {
123496
123496
  affectedFilesPendingEmit,
123497
123497
  pendingEmit === fullEmitForOptions ? fileId : (
123498
123498
  // Pending full emit per options
123499
- pendingEmit === 8 /* Dts */ ? [fileId] : (
123499
+ pendingEmit === 24 /* Dts */ ? [fileId] : (
123500
123500
  // Pending on Dts only
123501
123501
  [fileId, pendingEmit]
123502
123502
  )
@@ -123516,6 +123516,7 @@ function getBuildInfo2(state) {
123516
123516
  referencedMap,
123517
123517
  semanticDiagnosticsPerFile,
123518
123518
  emitDiagnosticsPerFile: toIncrementalBuildInfoEmitDiagnostics(),
123519
+ changeFileSet: toChangeFileSet(),
123519
123520
  affectedFilesPendingEmit,
123520
123521
  emitSignatures,
123521
123522
  latestChangedDtsFile,
@@ -123604,7 +123605,7 @@ function getBuildInfo2(state) {
123604
123605
  state.fileInfos.forEach((_value, key) => {
123605
123606
  const value = state.semanticDiagnosticsPerFile.get(key);
123606
123607
  if (!value) {
123607
- result = append(result, toFileId(key));
123608
+ if (!state.changedFilesSet.has(key)) result = append(result, toFileId(key));
123608
123609
  } else if (value.length) {
123609
123610
  result = append(result, [
123610
123611
  toFileId(key),
@@ -123671,6 +123672,15 @@ function getBuildInfo2(state) {
123671
123672
  return result;
123672
123673
  }) || array;
123673
123674
  }
123675
+ function toChangeFileSet() {
123676
+ let changeFileSet;
123677
+ if (state.changedFilesSet.size) {
123678
+ for (const path of arrayFrom(state.changedFilesSet.keys()).sort(compareStringsCaseSensitive)) {
123679
+ changeFileSet = append(changeFileSet, toFileId(path));
123680
+ }
123681
+ }
123682
+ return changeFileSet;
123683
+ }
123674
123684
  }
123675
123685
  function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
123676
123686
  let host;
@@ -123749,6 +123759,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123749
123759
  sourceFile
123750
123760
  );
123751
123761
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
123762
+ builderProgram.getDeclarationDiagnostics = getDeclarationDiagnostics2;
123752
123763
  builderProgram.emit = emit;
123753
123764
  builderProgram.releaseProgram = () => releaseCache(state);
123754
123765
  if (kind === 0 /* SemanticDiagnosticsBuilderProgram */) {
@@ -123773,21 +123784,31 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123773
123784
  }
123774
123785
  return emitSkippedWithNoDiagnostics;
123775
123786
  }
123776
- function emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
123787
+ function emitNextAffectedFileOrDtsErrors(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers, isForDtsErrors) {
123777
123788
  var _a, _b, _c, _d;
123778
123789
  Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123779
123790
  let affected = getNextAffectedFile(state, cancellationToken, host);
123780
123791
  const programEmitKind = getBuilderFileEmit(state.compilerOptions);
123781
- let emitKind = emitOnlyDtsFiles ? programEmitKind & 24 /* AllDts */ : programEmitKind;
123792
+ let emitKind = !isForDtsErrors ? emitOnlyDtsFiles ? programEmitKind & 56 /* AllDts */ : programEmitKind : 8 /* DtsErrors */;
123782
123793
  if (!affected) {
123783
123794
  if (!state.compilerOptions.outFile) {
123784
- const pendingAffectedFile = getNextAffectedFilePendingEmit(state, emitOnlyDtsFiles);
123795
+ const pendingAffectedFile = getNextAffectedFilePendingEmit(
123796
+ state,
123797
+ emitOnlyDtsFiles,
123798
+ isForDtsErrors
123799
+ );
123785
123800
  if (pendingAffectedFile) {
123786
123801
  ({ affectedFile: affected, emitKind } = pendingAffectedFile);
123787
123802
  } else {
123788
- const pendingForDiagnostics = getNextPendingEmitDiagnosticsFile(state);
123803
+ const pendingForDiagnostics = getNextPendingEmitDiagnosticsFile(
123804
+ state,
123805
+ isForDtsErrors
123806
+ );
123789
123807
  if (pendingForDiagnostics) {
123790
- (state.seenEmittedFiles ?? (state.seenEmittedFiles = /* @__PURE__ */ new Map())).set(pendingForDiagnostics.affectedFile.resolvedPath, pendingForDiagnostics.seenKind | 24 /* AllDts */);
123808
+ (state.seenEmittedFiles ?? (state.seenEmittedFiles = /* @__PURE__ */ new Map())).set(
123809
+ pendingForDiagnostics.affectedFile.resolvedPath,
123810
+ pendingForDiagnostics.seenKind | getBuilderFileEmitAllDts(isForDtsErrors)
123811
+ );
123791
123812
  return {
123792
123813
  result: { emitSkipped: true, diagnostics: pendingForDiagnostics.diagnostics },
123793
123814
  affected: pendingForDiagnostics.affectedFile
@@ -123796,14 +123817,18 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123796
123817
  }
123797
123818
  } else {
123798
123819
  if (state.programEmitPending) {
123799
- emitKind = state.programEmitPending;
123800
- if (emitOnlyDtsFiles) emitKind = emitKind & 24 /* AllDts */;
123820
+ emitKind = getPendingEmitKindWithSeen(
123821
+ state.programEmitPending,
123822
+ state.seenProgramEmit,
123823
+ emitOnlyDtsFiles,
123824
+ isForDtsErrors
123825
+ );
123801
123826
  if (emitKind) affected = state.program;
123802
123827
  }
123803
123828
  if (!affected && ((_a = state.emitDiagnosticsPerFile) == null ? void 0 : _a.size)) {
123804
123829
  const seenKind = state.seenProgramEmit || 0 /* None */;
123805
- if (!(seenKind & 24 /* AllDts */)) {
123806
- state.seenProgramEmit = 24 /* AllDts */ | seenKind;
123830
+ if (!(seenKind & getBuilderFileEmitAllDts(isForDtsErrors))) {
123831
+ state.seenProgramEmit = getBuilderFileEmitAllDts(isForDtsErrors) | seenKind;
123807
123832
  const diagnostics = [];
123808
123833
  state.emitDiagnosticsPerFile.forEach((d) => addRange(diagnostics, d));
123809
123834
  return {
@@ -123814,7 +123839,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123814
123839
  }
123815
123840
  }
123816
123841
  if (!affected) {
123817
- if (!getBuildInfoEmitPending(state)) return void 0;
123842
+ if (isForDtsErrors || !getBuildInfoEmitPending(state)) return void 0;
123818
123843
  const affected2 = state.program;
123819
123844
  const result2 = affected2.emitBuildInfo(
123820
123845
  writeFile2 || maybeBind(host, host.writeFile),
@@ -123826,8 +123851,8 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123826
123851
  }
123827
123852
  let emitOnly;
123828
123853
  if (emitKind & 7 /* AllJs */) emitOnly = 0 /* Js */;
123829
- if (emitKind & 24 /* AllDts */) emitOnly = emitOnly === void 0 ? 1 /* Dts */ : void 0;
123830
- const result = state.program.emit(
123854
+ if (emitKind & 56 /* AllDts */) emitOnly = emitOnly === void 0 ? 1 /* Dts */ : void 0;
123855
+ const result = !isForDtsErrors ? state.program.emit(
123831
123856
  affected === state.program ? void 0 : affected,
123832
123857
  getWriteFileCallback(writeFile2, customTransformers),
123833
123858
  cancellationToken,
@@ -123837,7 +123862,13 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123837
123862
  void 0,
123838
123863
  /*skipBuildInfo*/
123839
123864
  true
123840
- );
123865
+ ) : {
123866
+ emitSkipped: true,
123867
+ diagnostics: state.program.getDeclarationDiagnostics(
123868
+ affected === state.program ? void 0 : affected,
123869
+ cancellationToken
123870
+ )
123871
+ };
123841
123872
  if (affected !== state.program) {
123842
123873
  const affectedSourceFile = affected;
123843
123874
  state.seenAffectedFiles.add(affectedSourceFile.resolvedPath);
@@ -123854,18 +123885,31 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123854
123885
  state.changedFilesSet.clear();
123855
123886
  state.programEmitPending = state.changedFilesSet.size ? getPendingEmitKind(programEmitKind, emitKind) : state.programEmitPending ? getPendingEmitKind(state.programEmitPending, emitKind) : void 0;
123856
123887
  state.seenProgramEmit = emitKind | (state.seenProgramEmit || 0 /* None */);
123857
- let emitDiagnosticsPerFile;
123858
- result.diagnostics.forEach((d) => {
123859
- if (!d.file) return;
123860
- let diagnostics = emitDiagnosticsPerFile == null ? void 0 : emitDiagnosticsPerFile.get(d.file.resolvedPath);
123861
- if (!diagnostics) (emitDiagnosticsPerFile ?? (emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(d.file.resolvedPath, diagnostics = []);
123862
- diagnostics.push(d);
123863
- });
123864
- if (emitDiagnosticsPerFile) state.emitDiagnosticsPerFile = emitDiagnosticsPerFile;
123888
+ setEmitDiagnosticsPerFile(result.diagnostics);
123865
123889
  state.buildInfoEmitPending = true;
123866
123890
  }
123867
123891
  return { result, affected };
123868
123892
  }
123893
+ function setEmitDiagnosticsPerFile(diagnostics) {
123894
+ let emitDiagnosticsPerFile;
123895
+ diagnostics.forEach((d) => {
123896
+ if (!d.file) return;
123897
+ let diagnostics2 = emitDiagnosticsPerFile == null ? void 0 : emitDiagnosticsPerFile.get(d.file.resolvedPath);
123898
+ if (!diagnostics2) (emitDiagnosticsPerFile ?? (emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(d.file.resolvedPath, diagnostics2 = []);
123899
+ diagnostics2.push(d);
123900
+ });
123901
+ if (emitDiagnosticsPerFile) state.emitDiagnosticsPerFile = emitDiagnosticsPerFile;
123902
+ }
123903
+ function emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
123904
+ return emitNextAffectedFileOrDtsErrors(
123905
+ writeFile2,
123906
+ cancellationToken,
123907
+ emitOnlyDtsFiles,
123908
+ customTransformers,
123909
+ /*isForDtsErrors*/
123910
+ false
123911
+ );
123912
+ }
123869
123913
  function getWriteFileCallback(writeFile2, customTransformers) {
123870
123914
  Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123871
123915
  if (!getEmitDeclarations(state.compilerOptions)) return writeFile2 || maybeBind(host, host.writeFile);
@@ -123965,16 +124009,69 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123965
124009
  sourceMaps
123966
124010
  };
123967
124011
  } else {
123968
- clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles);
124012
+ clearAffectedFilesPendingEmit(
124013
+ state,
124014
+ emitOnlyDtsFiles,
124015
+ /*isForDtsErrors*/
124016
+ false
124017
+ );
123969
124018
  }
123970
124019
  }
123971
- return state.program.emit(
124020
+ const emitResult = state.program.emit(
123972
124021
  targetSourceFile,
123973
124022
  getWriteFileCallback(writeFile2, customTransformers),
123974
124023
  cancellationToken,
123975
124024
  emitOnlyDtsFiles,
123976
124025
  customTransformers
123977
124026
  );
124027
+ handleNonEmitBuilderWithEmitOrDtsErrors(
124028
+ targetSourceFile,
124029
+ emitOnlyDtsFiles,
124030
+ /*isForDtsErrors*/
124031
+ false,
124032
+ emitResult.diagnostics
124033
+ );
124034
+ return emitResult;
124035
+ }
124036
+ function handleNonEmitBuilderWithEmitOrDtsErrors(targetSourceFile, emitOnlyDtsFiles, isForDtsErrors, diagnostics) {
124037
+ if (!targetSourceFile && kind !== 1 /* EmitAndSemanticDiagnosticsBuilderProgram */) {
124038
+ clearAffectedFilesPendingEmit(state, emitOnlyDtsFiles, isForDtsErrors);
124039
+ setEmitDiagnosticsPerFile(diagnostics);
124040
+ }
124041
+ }
124042
+ function getDeclarationDiagnostics2(sourceFile, cancellationToken) {
124043
+ var _a;
124044
+ Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
124045
+ if (kind === 1 /* EmitAndSemanticDiagnosticsBuilderProgram */) {
124046
+ assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
124047
+ let affectedEmitResult;
124048
+ let diagnostics;
124049
+ while (affectedEmitResult = emitNextAffectedFileOrDtsErrors(
124050
+ /*writeFile*/
124051
+ void 0,
124052
+ cancellationToken,
124053
+ /*emitOnlyDtsFiles*/
124054
+ void 0,
124055
+ /*customTransformers*/
124056
+ void 0,
124057
+ /*isForDtsErrors*/
124058
+ true
124059
+ )) {
124060
+ if (!sourceFile) diagnostics = addRange(diagnostics, affectedEmitResult.result.diagnostics);
124061
+ }
124062
+ return (!sourceFile ? diagnostics : (_a = state.emitDiagnosticsPerFile) == null ? void 0 : _a.get(sourceFile.resolvedPath)) || emptyArray;
124063
+ } else {
124064
+ const result = state.program.getDeclarationDiagnostics(sourceFile, cancellationToken);
124065
+ handleNonEmitBuilderWithEmitOrDtsErrors(
124066
+ sourceFile,
124067
+ /*emitOnlyDtsFiles*/
124068
+ void 0,
124069
+ /*isForDtsErrors*/
124070
+ true,
124071
+ result
124072
+ );
124073
+ return result;
124074
+ }
123978
124075
  }
123979
124076
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
123980
124077
  Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
@@ -124052,7 +124149,7 @@ function toBuilderStateFileInfoForMultiEmit(fileInfo) {
124052
124149
  return isString(fileInfo) ? { version: fileInfo, signature: fileInfo, affectsGlobalScope: void 0, impliedFormat: void 0 } : isString(fileInfo.signature) ? fileInfo : { version: fileInfo.version, signature: fileInfo.signature === false ? void 0 : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
124053
124150
  }
124054
124151
  function toBuilderFileEmit(value, fullEmitForOptions) {
124055
- return isNumber(value) ? fullEmitForOptions : value[1] || 8 /* Dts */;
124152
+ return isNumber(value) ? fullEmitForOptions : value[1] || 24 /* Dts */;
124056
124153
  }
124057
124154
  function toProgramEmitPending(value, options) {
124058
124155
  return !value ? getBuilderFileEmit(options || {}) : value;
@@ -124066,6 +124163,7 @@ function createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath,
124066
124163
  let filePathsSetList;
124067
124164
  const latestChangedDtsFile = buildInfo.latestChangedDtsFile ? toAbsolutePath(buildInfo.latestChangedDtsFile) : void 0;
124068
124165
  const fileInfos = /* @__PURE__ */ new Map();
124166
+ const changedFilesSet = new Set(map(buildInfo.changeFileSet, toFilePath));
124069
124167
  if (isIncrementalBundleEmitBuildInfo(buildInfo)) {
124070
124168
  buildInfo.fileInfos.forEach((fileInfo, index) => {
124071
124169
  const path = toFilePath(index + 1);
@@ -124077,6 +124175,7 @@ function createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath,
124077
124175
  semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(buildInfo.semanticDiagnosticsPerFile),
124078
124176
  emitDiagnosticsPerFile: toPerFileEmitDiagnostics(buildInfo.emitDiagnosticsPerFile),
124079
124177
  hasReusableDiagnostic: true,
124178
+ changedFilesSet,
124080
124179
  latestChangedDtsFile,
124081
124180
  outSignature: buildInfo.outSignature,
124082
124181
  programEmitPending: buildInfo.pendingEmit === void 0 ? void 0 : toProgramEmitPending(buildInfo.pendingEmit, buildInfo.options),
@@ -124113,6 +124212,7 @@ function createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath,
124113
124212
  semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(buildInfo.semanticDiagnosticsPerFile),
124114
124213
  emitDiagnosticsPerFile: toPerFileEmitDiagnostics(buildInfo.emitDiagnosticsPerFile),
124115
124214
  hasReusableDiagnostic: true,
124215
+ changedFilesSet,
124116
124216
  affectedFilesPendingEmit: buildInfo.affectedFilesPendingEmit && arrayToMap(buildInfo.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
124117
124217
  latestChangedDtsFile,
124118
124218
  emitSignatures: (emitSignatures == null ? void 0 : emitSignatures.size) ? emitSignatures : void 0,
@@ -124165,7 +124265,7 @@ function createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath,
124165
124265
  const semanticDiagnostics = new Map(
124166
124266
  mapDefinedIterator(
124167
124267
  fileInfos.keys(),
124168
- (key) => [key, emptyArray]
124268
+ (key) => !changedFilesSet.has(key) ? [key, emptyArray] : void 0
124169
124269
  )
124170
124270
  );
124171
124271
  diagnostics == null ? void 0 : diagnostics.forEach((value) => {
@@ -125734,7 +125834,7 @@ function toFileName(file, fileNameConvertor) {
125734
125834
  return fileNameConvertor ? fileNameConvertor(fileName) : fileName;
125735
125835
  }
125736
125836
  function emitFilesAndReportErrors(program, reportDiagnostic, write, reportSummary, writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
125737
- const isListFilesOnly = !!program.getCompilerOptions().listFilesOnly;
125837
+ const options = program.getCompilerOptions();
125738
125838
  const allDiagnostics = program.getConfigFileParsingDiagnostics().slice();
125739
125839
  const configFileParsingDiagnosticsLength = allDiagnostics.length;
125740
125840
  addRange(allDiagnostics, program.getSyntacticDiagnostics(
@@ -125744,7 +125844,7 @@ function emitFilesAndReportErrors(program, reportDiagnostic, write, reportSummar
125744
125844
  ));
125745
125845
  if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
125746
125846
  addRange(allDiagnostics, program.getOptionsDiagnostics(cancellationToken));
125747
- if (!isListFilesOnly) {
125847
+ if (!options.listFilesOnly) {
125748
125848
  addRange(allDiagnostics, program.getGlobalDiagnostics(cancellationToken));
125749
125849
  if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
125750
125850
  addRange(allDiagnostics, program.getSemanticDiagnostics(
@@ -125753,9 +125853,16 @@ function emitFilesAndReportErrors(program, reportDiagnostic, write, reportSummar
125753
125853
  cancellationToken
125754
125854
  ));
125755
125855
  }
125856
+ if (options.noEmit && getEmitDeclarations(options) && allDiagnostics.length === configFileParsingDiagnosticsLength) {
125857
+ addRange(allDiagnostics, program.getDeclarationDiagnostics(
125858
+ /*sourceFile*/
125859
+ void 0,
125860
+ cancellationToken
125861
+ ));
125862
+ }
125756
125863
  }
125757
125864
  }
125758
- const emitResult = isListFilesOnly ? { emitSkipped: true, diagnostics: emptyArray } : program.emit(
125865
+ const emitResult = options.listFilesOnly ? { emitSkipped: true, diagnostics: emptyArray } : program.emit(
125759
125866
  /*targetSourceFile*/
125760
125867
  void 0,
125761
125868
  writeFile2,
@@ -127574,7 +127681,7 @@ function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime,
127574
127681
  }
127575
127682
  }
127576
127683
  function getUpToDateStatusWorker(state, project, resolvedPath) {
127577
- var _a, _b, _c;
127684
+ var _a, _b, _c, _d, _e;
127578
127685
  if (!project.fileNames.length && !canJsonReportNoInputFiles(project.raw)) {
127579
127686
  return {
127580
127687
  type: 15 /* ContainerOnly */
@@ -127636,19 +127743,25 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127636
127743
  };
127637
127744
  }
127638
127745
  if (incrementalBuildInfo) {
127639
- if (!project.options.noCheck && (((_a = incrementalBuildInfo.semanticDiagnosticsPerFile) == null ? void 0 : _a.length) || !project.options.noEmit && getEmitDeclarations(project.options) && ((_b = incrementalBuildInfo.emitDiagnosticsPerFile) == null ? void 0 : _b.length))) {
127746
+ if (!project.options.noCheck && (((_a = incrementalBuildInfo.changeFileSet) == null ? void 0 : _a.length) || ((_b = incrementalBuildInfo.semanticDiagnosticsPerFile) == null ? void 0 : _b.length) || getEmitDeclarations(project.options) && ((_c = incrementalBuildInfo.emitDiagnosticsPerFile) == null ? void 0 : _c.length))) {
127640
127747
  return {
127641
127748
  type: 8 /* OutOfDateBuildInfoWithErrors */,
127642
127749
  buildInfoFile: buildInfoPath
127643
127750
  };
127644
127751
  }
127645
- if (!project.options.noEmit && (((_c = incrementalBuildInfo.affectedFilesPendingEmit) == null ? void 0 : _c.length) || incrementalBuildInfo.pendingEmit !== void 0)) {
127752
+ if (!project.options.noEmit && (((_d = incrementalBuildInfo.changeFileSet) == null ? void 0 : _d.length) || ((_e = incrementalBuildInfo.affectedFilesPendingEmit) == null ? void 0 : _e.length) || incrementalBuildInfo.pendingEmit !== void 0)) {
127646
127753
  return {
127647
127754
  type: 7 /* OutOfDateBuildInfoWithPendingEmit */,
127648
127755
  buildInfoFile: buildInfoPath
127649
127756
  };
127650
127757
  }
127651
- if (!project.options.noEmit && getPendingEmitKind(project.options, incrementalBuildInfo.options || {})) {
127758
+ if ((!project.options.noEmit || project.options.noEmit && getEmitDeclarations(project.options)) && getPendingEmitKindWithSeen(
127759
+ project.options,
127760
+ incrementalBuildInfo.options || {},
127761
+ /*emitOnlyDtsFiles*/
127762
+ void 0,
127763
+ !!project.options.noEmit
127764
+ )) {
127652
127765
  return {
127653
127766
  type: 9 /* OutOfDateOptions */,
127654
127767
  buildInfoFile: buildInfoPath