typescript 5.3.0-dev.20231009 → 5.3.0-dev.20231010

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.3";
21
- var version = `${versionMajorMinor}.0-dev.20231009`;
21
+ var version = `${versionMajorMinor}.0-dev.20231010`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -13637,6 +13637,7 @@ function tryGetModuleSpecifierFromDeclaration(node) {
13637
13637
  true
13638
13638
  ))) == null ? void 0 : _a.arguments[0];
13639
13639
  case 272 /* ImportDeclaration */:
13640
+ case 278 /* ExportDeclaration */:
13640
13641
  return tryCast(node.moduleSpecifier, isStringLiteralLike);
13641
13642
  case 271 /* ImportEqualsDeclaration */:
13642
13643
  return tryCast((_b = tryCast(node.moduleReference, isExternalModuleReference)) == null ? void 0 : _b.expression, isStringLiteralLike);
@@ -13648,6 +13649,8 @@ function tryGetModuleSpecifierFromDeclaration(node) {
13648
13649
  return tryCast(node.parent.parent.moduleSpecifier, isStringLiteralLike);
13649
13650
  case 276 /* ImportSpecifier */:
13650
13651
  return tryCast(node.parent.parent.parent.moduleSpecifier, isStringLiteralLike);
13652
+ case 205 /* ImportType */:
13653
+ return isLiteralImportTypeNode(node) ? node.argument.literal : void 0;
13651
13654
  default:
13652
13655
  Debug.assertNever(node);
13653
13656
  }
@@ -65732,7 +65735,7 @@ function createTypeChecker(host) {
65732
65735
  return createFlowType(narrowedType, isIncomplete(flowType));
65733
65736
  }
65734
65737
  function getTypeAtSwitchClause(flow) {
65735
- const expr = flow.switchStatement.expression;
65738
+ const expr = skipParentheses(flow.switchStatement.expression);
65736
65739
  const flowType = getTypeAtFlowNode(flow.antecedent);
65737
65740
  let type = getTypeFromFlowType(flowType);
65738
65741
  if (isMatchingReference(reference, expr)) {
@@ -82326,7 +82329,16 @@ function createTypeChecker(host) {
82326
82329
  }
82327
82330
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
82328
82331
  },
82329
- isImportRequiredByAugmentation
82332
+ isImportRequiredByAugmentation,
82333
+ tryFindAmbientModule: (moduleReferenceExpression) => {
82334
+ const node = getParseTreeNode(moduleReferenceExpression);
82335
+ const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0;
82336
+ return moduleSpecifier !== void 0 ? tryFindAmbientModule(
82337
+ moduleSpecifier,
82338
+ /*withAugmentations*/
82339
+ true
82340
+ ) : void 0;
82341
+ }
82330
82342
  };
82331
82343
  function isImportRequiredByAugmentation(node) {
82332
82344
  const file = getSourceFileOfNode(node);
@@ -107086,6 +107098,17 @@ function transformDeclarations(context) {
107086
107098
  const container = getSourceFileOfNode(node);
107087
107099
  refs.set(getOriginalNodeId(container), container);
107088
107100
  }
107101
+ function trackReferencedAmbientModuleFromImport(node) {
107102
+ const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node);
107103
+ const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier);
107104
+ if (symbol == null ? void 0 : symbol.declarations) {
107105
+ for (const decl of symbol.declarations) {
107106
+ if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) {
107107
+ trackReferencedAmbientModule(decl, symbol);
107108
+ }
107109
+ }
107110
+ }
107111
+ }
107089
107112
  function handleSymbolAccessibilityError(symbolAccessibilityResult) {
107090
107113
  if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
107091
107114
  if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
@@ -108033,6 +108056,7 @@ function transformDeclarations(context) {
108033
108056
  case 205 /* ImportType */: {
108034
108057
  if (!isLiteralImportTypeNode(input))
108035
108058
  return cleanup(input);
108059
+ trackReferencedAmbientModuleFromImport(input);
108036
108060
  return cleanup(factory2.updateImportTypeNode(
108037
108061
  input,
108038
108062
  factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)),
@@ -108084,6 +108108,7 @@ function transformDeclarations(context) {
108084
108108
  resultHasExternalModuleIndicator = true;
108085
108109
  }
108086
108110
  resultHasScopeMarker = true;
108111
+ trackReferencedAmbientModuleFromImport(input);
108087
108112
  return factory2.updateExportDeclaration(
108088
108113
  input,
108089
108114
  input.modifiers,
@@ -108158,10 +108183,18 @@ function transformDeclarations(context) {
108158
108183
  return;
108159
108184
  switch (input.kind) {
108160
108185
  case 271 /* ImportEqualsDeclaration */: {
108161
- return transformImportEqualsDeclaration(input);
108186
+ const transformed = transformImportEqualsDeclaration(input);
108187
+ if (transformed) {
108188
+ trackReferencedAmbientModuleFromImport(input);
108189
+ }
108190
+ return transformed;
108162
108191
  }
108163
108192
  case 272 /* ImportDeclaration */: {
108164
- return transformImportDeclaration(input);
108193
+ const transformed = transformImportDeclaration(input);
108194
+ if (transformed) {
108195
+ trackReferencedAmbientModuleFromImport(input);
108196
+ }
108197
+ return transformed;
108165
108198
  }
108166
108199
  }
108167
108200
  if (isDeclaration(input) && isDeclarationAndNotVisible(input))
@@ -109764,7 +109797,8 @@ var notImplementedResolver = {
109764
109797
  getSymbolOfExternalModuleSpecifier: notImplemented,
109765
109798
  isBindingCapturedByNode: notImplemented,
109766
109799
  getDeclarationStatementsForSourceFile: notImplemented,
109767
- isImportRequiredByAugmentation: notImplemented
109800
+ isImportRequiredByAugmentation: notImplemented,
109801
+ tryFindAmbientModule: notImplemented
109768
109802
  };
109769
109803
  function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
109770
109804
  var _a;
@@ -122557,7 +122591,7 @@ function createIncrementalProgram({
122557
122591
  }
122558
122592
  function createWatchProgram(host) {
122559
122593
  let builderProgram;
122560
- let reloadLevel;
122594
+ let updateLevel;
122561
122595
  let missingFilesMap;
122562
122596
  let watchedWildcardDirectories;
122563
122597
  let timerToUpdateProgram;
@@ -122916,7 +122950,7 @@ function createWatchProgram(host) {
122916
122950
  }
122917
122951
  function scheduleProgramReload() {
122918
122952
  Debug.assert(!!configFileName);
122919
- reloadLevel = 2 /* Full */;
122953
+ updateLevel = 2 /* Full */;
122920
122954
  scheduleProgramUpdate();
122921
122955
  }
122922
122956
  function updateProgramWithWatchStatus() {
@@ -122926,8 +122960,8 @@ function createWatchProgram(host) {
122926
122960
  }
122927
122961
  function updateProgram() {
122928
122962
  var _a, _b, _c, _d;
122929
- switch (reloadLevel) {
122930
- case 1 /* Partial */:
122963
+ switch (updateLevel) {
122964
+ case 1 /* RootNamesAndUpdate */:
122931
122965
  (_a = perfLogger) == null ? void 0 : _a.logStartUpdateProgram("PartialConfigReload");
122932
122966
  reloadFileNamesFromConfigFile();
122933
122967
  break;
@@ -122947,7 +122981,7 @@ function createWatchProgram(host) {
122947
122981
  writeLog("Reloading new file names and options");
122948
122982
  Debug.assert(compilerOptions);
122949
122983
  Debug.assert(configFileName);
122950
- reloadLevel = 0 /* None */;
122984
+ updateLevel = 0 /* Update */;
122951
122985
  rootFileNames = getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, getNormalizedAbsolutePath(getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
122952
122986
  if (updateErrorForNoInputFiles(rootFileNames, getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
122953
122987
  hasChangedConfigFileParsingErrors = true;
@@ -122957,7 +122991,7 @@ function createWatchProgram(host) {
122957
122991
  function reloadConfigFile() {
122958
122992
  Debug.assert(configFileName);
122959
122993
  writeLog(`Reloading config file: ${configFileName}`);
122960
- reloadLevel = 0 /* None */;
122994
+ updateLevel = 0 /* Update */;
122961
122995
  if (cachedDirectoryStructureHost) {
122962
122996
  cachedDirectoryStructureHost.clearCache();
122963
122997
  }
@@ -122994,9 +123028,9 @@ function createWatchProgram(host) {
122994
123028
  const configPath = toPath3(configFileName2);
122995
123029
  let config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath);
122996
123030
  if (config) {
122997
- if (!config.reloadLevel)
123031
+ if (!config.updateLevel)
122998
123032
  return config.parsedCommandLine;
122999
- if (config.parsedCommandLine && config.reloadLevel === 1 /* Partial */ && !host.getParsedCommandLine) {
123033
+ if (config.parsedCommandLine && config.updateLevel === 1 /* RootNamesAndUpdate */ && !host.getParsedCommandLine) {
123000
123034
  writeLog("Reloading new file names and options");
123001
123035
  Debug.assert(compilerOptions);
123002
123036
  const fileNames = getFileNamesFromConfigSpecs(
@@ -123006,7 +123040,7 @@ function createWatchProgram(host) {
123006
123040
  parseConfigFileHost
123007
123041
  );
123008
123042
  config.parsedCommandLine = { ...config.parsedCommandLine, fileNames };
123009
- config.reloadLevel = void 0;
123043
+ config.updateLevel = void 0;
123010
123044
  return config.parsedCommandLine;
123011
123045
  }
123012
123046
  }
@@ -123014,7 +123048,7 @@ function createWatchProgram(host) {
123014
123048
  const parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName2) : getParsedCommandLineFromConfigFileHost(configFileName2);
123015
123049
  if (config) {
123016
123050
  config.parsedCommandLine = parsedCommandLine;
123017
- config.reloadLevel = void 0;
123051
+ config.updateLevel = void 0;
123018
123052
  } else {
123019
123053
  (parsedConfigs || (parsedConfigs = /* @__PURE__ */ new Map())).set(configPath, config = { parsedCommandLine });
123020
123054
  }
@@ -123111,8 +123145,8 @@ function createWatchProgram(host) {
123111
123145
  toPath: toPath3
123112
123146
  }))
123113
123147
  return;
123114
- if (reloadLevel !== 2 /* Full */) {
123115
- reloadLevel = 1 /* Partial */;
123148
+ if (updateLevel !== 2 /* Full */) {
123149
+ updateLevel = 1 /* RootNamesAndUpdate */;
123116
123150
  scheduleProgramUpdate();
123117
123151
  }
123118
123152
  },
@@ -123138,11 +123172,11 @@ function createWatchProgram(host) {
123138
123172
  return;
123139
123173
  projects.forEach((projectPath) => {
123140
123174
  if (configFileName && toPath3(configFileName) === projectPath) {
123141
- reloadLevel = 2 /* Full */;
123175
+ updateLevel = 2 /* Full */;
123142
123176
  } else {
123143
123177
  const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath);
123144
123178
  if (config)
123145
- config.reloadLevel = 2 /* Full */;
123179
+ config.updateLevel = 2 /* Full */;
123146
123180
  resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath);
123147
123181
  }
123148
123182
  scheduleProgramUpdate();
@@ -123163,7 +123197,7 @@ function createWatchProgram(host) {
123163
123197
  updateCachedSystemWithFile(configFileName2, configPath, eventKind);
123164
123198
  const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath);
123165
123199
  if (config)
123166
- config.reloadLevel = 2 /* Full */;
123200
+ config.updateLevel = 2 /* Full */;
123167
123201
  resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath);
123168
123202
  scheduleProgramUpdate();
123169
123203
  },
@@ -123201,8 +123235,8 @@ function createWatchProgram(host) {
123201
123235
  toPath: toPath3
123202
123236
  }))
123203
123237
  return;
123204
- if (config.reloadLevel !== 2 /* Full */) {
123205
- config.reloadLevel = 1 /* Partial */;
123238
+ if (config.updateLevel !== 2 /* Full */) {
123239
+ config.updateLevel = 1 /* RootNamesAndUpdate */;
123206
123240
  scheduleProgramUpdate();
123207
123241
  }
123208
123242
  },
@@ -123644,12 +123678,12 @@ function clearProjectStatus(state, resolved) {
123644
123678
  state.projectStatus.delete(resolved);
123645
123679
  state.diagnostics.delete(resolved);
123646
123680
  }
123647
- function addProjToQueue({ projectPendingBuild }, proj, reloadLevel) {
123681
+ function addProjToQueue({ projectPendingBuild }, proj, updateLevel) {
123648
123682
  const value = projectPendingBuild.get(proj);
123649
123683
  if (value === void 0) {
123650
- projectPendingBuild.set(proj, reloadLevel);
123651
- } else if (value < reloadLevel) {
123652
- projectPendingBuild.set(proj, reloadLevel);
123684
+ projectPendingBuild.set(proj, updateLevel);
123685
+ } else if (value < updateLevel) {
123686
+ projectPendingBuild.set(proj, updateLevel);
123653
123687
  }
123654
123688
  }
123655
123689
  function setupInitialBuild(state, cancellationToken) {
@@ -123663,7 +123697,7 @@ function setupInitialBuild(state, cancellationToken) {
123663
123697
  buildOrder.forEach(
123664
123698
  (configFileName) => state.projectPendingBuild.set(
123665
123699
  toResolvedConfigFilePath(state, configFileName),
123666
- 0 /* None */
123700
+ 0 /* Update */
123667
123701
  )
123668
123702
  );
123669
123703
  if (cancellationToken) {
@@ -124099,8 +124133,8 @@ function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
124099
124133
  for (let projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
124100
124134
  const project = buildOrder[projectIndex];
124101
124135
  const projectPath = toResolvedConfigFilePath(state, project);
124102
- const reloadLevel = state.projectPendingBuild.get(projectPath);
124103
- if (reloadLevel === void 0)
124136
+ const updateLevel = state.projectPendingBuild.get(projectPath);
124137
+ if (updateLevel === void 0)
124104
124138
  continue;
124105
124139
  if (reportQueue) {
124106
124140
  reportQueue = false;
@@ -124112,13 +124146,13 @@ function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
124112
124146
  projectPendingBuild.delete(projectPath);
124113
124147
  continue;
124114
124148
  }
124115
- if (reloadLevel === 2 /* Full */) {
124149
+ if (updateLevel === 2 /* Full */) {
124116
124150
  watchConfigFile(state, project, projectPath, config);
124117
124151
  watchExtendedConfigFiles(state, projectPath, config);
124118
124152
  watchWildCardDirectories(state, project, projectPath, config);
124119
124153
  watchInputFiles(state, project, projectPath, config);
124120
124154
  watchPackageJsonFiles(state, project, projectPath, config);
124121
- } else if (reloadLevel === 1 /* Partial */) {
124155
+ } else if (updateLevel === 1 /* RootNamesAndUpdate */) {
124122
124156
  config.fileNames = getFileNamesFromConfigSpecs(config.options.configFile.configFileSpecs, getDirectoryPath(project), config.options, state.parseConfigFileHost);
124123
124157
  updateErrorForNoInputFiles(config.fileNames, project, config.options.configFile.configFileSpecs, config.errors, canJsonReportNoInputFiles(config.raw));
124124
124158
  watchInputFiles(state, project, projectPath, config);
@@ -124705,7 +124739,7 @@ function queueReferencingProjects(state, project, projectPath, projectIndex, con
124705
124739
  break;
124706
124740
  }
124707
124741
  }
124708
- addProjToQueue(state, nextProjectPath, 0 /* None */);
124742
+ addProjToQueue(state, nextProjectPath, 0 /* Update */);
124709
124743
  break;
124710
124744
  }
124711
124745
  }
@@ -124774,7 +124808,7 @@ function cleanWorker(state, project, onlyReferences) {
124774
124808
  filesToDelete.push(output);
124775
124809
  } else {
124776
124810
  host.deleteFile(output);
124777
- invalidateProject(state, resolvedPath, 0 /* None */);
124811
+ invalidateProject(state, resolvedPath, 0 /* Update */);
124778
124812
  }
124779
124813
  }
124780
124814
  }
@@ -124785,22 +124819,22 @@ function cleanWorker(state, project, onlyReferences) {
124785
124819
  }
124786
124820
  return 0 /* Success */;
124787
124821
  }
124788
- function invalidateProject(state, resolved, reloadLevel) {
124789
- if (state.host.getParsedCommandLine && reloadLevel === 1 /* Partial */) {
124790
- reloadLevel = 2 /* Full */;
124822
+ function invalidateProject(state, resolved, updateLevel) {
124823
+ if (state.host.getParsedCommandLine && updateLevel === 1 /* RootNamesAndUpdate */) {
124824
+ updateLevel = 2 /* Full */;
124791
124825
  }
124792
- if (reloadLevel === 2 /* Full */) {
124826
+ if (updateLevel === 2 /* Full */) {
124793
124827
  state.configFileCache.delete(resolved);
124794
124828
  state.buildOrder = void 0;
124795
124829
  }
124796
124830
  state.needsSummary = true;
124797
124831
  clearProjectStatus(state, resolved);
124798
- addProjToQueue(state, resolved, reloadLevel);
124832
+ addProjToQueue(state, resolved, updateLevel);
124799
124833
  enableCache(state);
124800
124834
  }
124801
- function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
124835
+ function invalidateProjectAndScheduleBuilds(state, resolvedPath, updateLevel) {
124802
124836
  state.reportFileChangeDetected = true;
124803
- invalidateProject(state, resolvedPath, reloadLevel);
124837
+ invalidateProject(state, resolvedPath, updateLevel);
124804
124838
  scheduleBuildInvalidatedProject(
124805
124839
  state,
124806
124840
  250,
@@ -124931,7 +124965,7 @@ function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
124931
124965
  toPath: (fileName) => toPath2(state, fileName)
124932
124966
  }))
124933
124967
  return;
124934
- invalidateProjectAndScheduleBuilds(state, resolvedPath, 1 /* Partial */);
124968
+ invalidateProjectAndScheduleBuilds(state, resolvedPath, 1 /* RootNamesAndUpdate */);
124935
124969
  },
124936
124970
  flags,
124937
124971
  parsed == null ? void 0 : parsed.watchOptions,
@@ -124950,7 +124984,7 @@ function watchInputFiles(state, resolved, resolvedPath, parsed) {
124950
124984
  createNewValue: (_path, input) => watchFile(
124951
124985
  state,
124952
124986
  input,
124953
- () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* None */),
124987
+ () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */),
124954
124988
  250 /* Low */,
124955
124989
  parsed == null ? void 0 : parsed.watchOptions,
124956
124990
  WatchType.SourceFile,
@@ -124970,7 +125004,7 @@ function watchPackageJsonFiles(state, resolved, resolvedPath, parsed) {
124970
125004
  createNewValue: (path, _input) => watchFile(
124971
125005
  state,
124972
125006
  path,
124973
- () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* None */),
125007
+ () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */),
124974
125008
  2e3 /* High */,
124975
125009
  parsed == null ? void 0 : parsed.watchOptions,
124976
125010
  WatchType.PackageJson,
@@ -125041,7 +125075,7 @@ function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, opti
125041
125075
  const configFilePath = toResolvedConfigFilePath(state, configFileName);
125042
125076
  return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
125043
125077
  },
125044
- invalidateProject: (configFilePath, reloadLevel) => invalidateProject(state, configFilePath, reloadLevel || 0 /* None */),
125078
+ invalidateProject: (configFilePath, updateLevel) => invalidateProject(state, configFilePath, updateLevel || 0 /* Update */),
125045
125079
  close: () => stopWatching(state)
125046
125080
  };
125047
125081
  }