typescript 5.1.0-dev.20230331 → 5.1.0-dev.20230401

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.1";
21
- var version = `${versionMajorMinor}.0-dev.20230331`;
21
+ var version = `${versionMajorMinor}.0-dev.20230401`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -16219,6 +16219,9 @@ function getAllowSyntheticDefaultImports(compilerOptions) {
16219
16219
  function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
16220
16220
  return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
16221
16221
  }
16222
+ function shouldResolveJsRequire(compilerOptions) {
16223
+ return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
16224
+ }
16222
16225
  function getResolvePackageJsonExports(compilerOptions) {
16223
16226
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
16224
16227
  if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
@@ -34131,7 +34134,8 @@ var commandOptionsWithoutBuild = [
34131
34134
  affectsBuildInfo: true,
34132
34135
  category: Diagnostics.Modules,
34133
34136
  description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
34134
- defaultValueDescription: false
34137
+ defaultValueDescription: false,
34138
+ transpileOptionValue: void 0
34135
34139
  },
34136
34140
  {
34137
34141
  name: "resolvePackageJsonExports",
@@ -41292,7 +41296,7 @@ function createBinder() {
41292
41296
  }
41293
41297
  if (!isBindingPattern(node.name)) {
41294
41298
  const possibleVariableDecl = node.kind === 258 /* VariableDeclaration */ ? node : node.parent.parent;
41295
- if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Bundler */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
41299
+ if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
41296
41300
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
41297
41301
  } else if (isBlockOrCatchScoped(node)) {
41298
41302
  bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
@@ -44903,7 +44907,7 @@ function createTypeChecker(host) {
44903
44907
  const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
44904
44908
  const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
44905
44909
  if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
44906
- if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
44910
+ if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
44907
44911
  const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
44908
44912
  const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
44909
44913
  const exportAssignment = exportEqualsSymbol.valueDeclaration;
@@ -45071,7 +45075,7 @@ function createTypeChecker(host) {
45071
45075
  if (!isIdentifier(name)) {
45072
45076
  return void 0;
45073
45077
  }
45074
- const suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions));
45078
+ const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
45075
45079
  const targetSymbol = resolveESModuleSymbol(
45076
45080
  moduleSymbol,
45077
45081
  moduleSpecifier,
@@ -49713,7 +49717,7 @@ function createTypeChecker(host) {
49713
49717
  return;
49714
49718
  }
49715
49719
  let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
49716
- if (verbatimTargetName === "export=" /* ExportEquals */ && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
49720
+ if (verbatimTargetName === "export=" /* ExportEquals */ && allowSyntheticDefaultImports) {
49717
49721
  verbatimTargetName = "default" /* Default */;
49718
49722
  }
49719
49723
  const targetName = getInternalSymbolName(target, verbatimTargetName);
@@ -70936,7 +70940,7 @@ function createTypeChecker(host) {
70936
70940
  return anyType;
70937
70941
  }
70938
70942
  }
70939
- if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */ && isCommonJsRequire(node)) {
70943
+ if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) {
70940
70944
  return resolveExternalModuleTypeByLiteral(node.arguments[0]);
70941
70945
  }
70942
70946
  const returnType = getReturnTypeOfSignature(signature);
@@ -114677,7 +114681,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
114677
114681
  false
114678
114682
  );
114679
114683
  }
114680
- const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== 100 /* Bundler */;
114684
+ const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options);
114681
114685
  if (file.flags & 2097152 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
114682
114686
  collectDynamicImportOrRequireCalls(file);
114683
114687
  }
@@ -118090,6 +118094,79 @@ function canWatchDirectoryOrFile(dirPath) {
118090
118094
  }
118091
118095
  return true;
118092
118096
  }
118097
+ function canWatchAtTypes(atTypes, rootPath) {
118098
+ const dirPath = getDirectoryPath(getDirectoryPath(atTypes));
118099
+ return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
118100
+ }
118101
+ function isInDirectoryPath(dir, file) {
118102
+ if (dir === void 0 || file.length <= dir.length) {
118103
+ return false;
118104
+ }
118105
+ return startsWith(file, dir) && file[dir.length] === directorySeparator;
118106
+ }
118107
+ function canWatchAffectingLocation(filePath) {
118108
+ return canWatchDirectoryOrFile(filePath);
118109
+ }
118110
+ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootSplitLength, getCurrentDirectory) {
118111
+ if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
118112
+ failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
118113
+ const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
118114
+ const failedLookupSplit = failedLookupLocation.split(directorySeparator);
118115
+ Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
118116
+ if (failedLookupPathSplit.length > rootSplitLength + 1) {
118117
+ return {
118118
+ dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
118119
+ dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
118120
+ };
118121
+ } else {
118122
+ return {
118123
+ dir: rootDir,
118124
+ dirPath: rootPath,
118125
+ nonRecursive: false
118126
+ };
118127
+ }
118128
+ }
118129
+ return getDirectoryToWatchFromFailedLookupLocationDirectory(
118130
+ getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
118131
+ getDirectoryPath(failedLookupLocationPath),
118132
+ rootPath
118133
+ );
118134
+ }
118135
+ function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath, rootPath) {
118136
+ while (pathContainsNodeModules(dirPath)) {
118137
+ dir = getDirectoryPath(dir);
118138
+ dirPath = getDirectoryPath(dirPath);
118139
+ }
118140
+ if (isNodeModulesDirectory(dirPath)) {
118141
+ return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
118142
+ }
118143
+ let nonRecursive = true;
118144
+ let subDirectoryPath, subDirectory;
118145
+ if (rootPath !== void 0) {
118146
+ while (!isInDirectoryPath(dirPath, rootPath)) {
118147
+ const parentPath = getDirectoryPath(dirPath);
118148
+ if (parentPath === dirPath) {
118149
+ break;
118150
+ }
118151
+ nonRecursive = false;
118152
+ subDirectoryPath = dirPath;
118153
+ subDirectory = dir;
118154
+ dirPath = parentPath;
118155
+ dir = getDirectoryPath(dir);
118156
+ }
118157
+ }
118158
+ return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
118159
+ }
118160
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, filterCustomPath) {
118161
+ if (isInDirectoryPath(rootPath, typeRootPath)) {
118162
+ return rootPath;
118163
+ }
118164
+ const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath, rootPath);
118165
+ return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
118166
+ }
118167
+ function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory) {
118168
+ return rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
118169
+ }
118093
118170
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
118094
118171
  let filesWithChangedSetOfUnresolvedImports;
118095
118172
  let filesWithInvalidatedResolutions;
@@ -118124,7 +118201,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118124
118201
  const customFailedLookupPaths = /* @__PURE__ */ new Map();
118125
118202
  const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
118126
118203
  const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
118127
- const rootDir = rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
118204
+ const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
118128
118205
  const rootPath = rootDir && resolutionHost.toPath(rootDir);
118129
118206
  const rootSplitLength = rootPath !== void 0 ? rootPath.split(directorySeparator).length : 0;
118130
118207
  const typeRootsWatches = /* @__PURE__ */ new Map();
@@ -118157,12 +118234,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118157
118234
  function getResolvedTypeReferenceDirective(resolution) {
118158
118235
  return resolution.resolvedTypeReferenceDirective;
118159
118236
  }
118160
- function isInDirectoryPath(dir, file) {
118161
- if (dir === void 0 || file.length <= dir.length) {
118162
- return false;
118163
- }
118164
- return startsWith(file, dir) && file[dir.length] === directorySeparator;
118165
- }
118166
118237
  function clear2() {
118167
118238
  clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
118168
118239
  clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
@@ -118446,55 +118517,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118446
118517
  function isNodeModulesAtTypesDirectory(dirPath) {
118447
118518
  return endsWith(dirPath, "/node_modules/@types");
118448
118519
  }
118449
- function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
118450
- if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
118451
- failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
118452
- const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
118453
- const failedLookupSplit = failedLookupLocation.split(directorySeparator);
118454
- Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
118455
- if (failedLookupPathSplit.length > rootSplitLength + 1) {
118456
- return {
118457
- dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
118458
- dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
118459
- };
118460
- } else {
118461
- return {
118462
- dir: rootDir,
118463
- dirPath: rootPath,
118464
- nonRecursive: false
118465
- };
118466
- }
118467
- }
118468
- return getDirectoryToWatchFromFailedLookupLocationDirectory(
118469
- getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
118470
- getDirectoryPath(failedLookupLocationPath)
118471
- );
118472
- }
118473
- function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
118474
- while (pathContainsNodeModules(dirPath)) {
118475
- dir = getDirectoryPath(dir);
118476
- dirPath = getDirectoryPath(dirPath);
118477
- }
118478
- if (isNodeModulesDirectory(dirPath)) {
118479
- return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
118480
- }
118481
- let nonRecursive = true;
118482
- let subDirectoryPath, subDirectory;
118483
- if (rootPath !== void 0) {
118484
- while (!isInDirectoryPath(dirPath, rootPath)) {
118485
- const parentPath = getDirectoryPath(dirPath);
118486
- if (parentPath === dirPath) {
118487
- break;
118488
- }
118489
- nonRecursive = false;
118490
- subDirectoryPath = dirPath;
118491
- subDirectory = dir;
118492
- dirPath = parentPath;
118493
- dir = getDirectoryPath(dir);
118494
- }
118495
- }
118496
- return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
118497
- }
118498
118520
  function isPathWithDefaultFailedLookupExtension(path) {
118499
118521
  return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
118500
118522
  }
@@ -118533,7 +118555,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118533
118555
  if (failedLookupLocations) {
118534
118556
  for (const failedLookupLocation of failedLookupLocations) {
118535
118557
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
118536
- const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
118558
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
118559
+ failedLookupLocation,
118560
+ failedLookupLocationPath,
118561
+ rootDir,
118562
+ rootPath,
118563
+ rootSplitLength,
118564
+ getCurrentDirectory
118565
+ );
118537
118566
  if (toWatch) {
118538
118567
  const { dir, dirPath, nonRecursive } = toWatch;
118539
118568
  if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
@@ -118601,7 +118630,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118601
118630
  }
118602
118631
  const paths = /* @__PURE__ */ new Set();
118603
118632
  paths.add(locationToWatch);
118604
- let actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
118633
+ let actualWatcher = canWatchAffectingLocation(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
118605
118634
  cachedDirectoryStructureHost == null ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
118606
118635
  const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
118607
118636
  paths.forEach((path) => {
@@ -118669,7 +118698,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118669
118698
  let removeAtRoot = false;
118670
118699
  for (const failedLookupLocation of failedLookupLocations) {
118671
118700
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
118672
- const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
118701
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
118702
+ failedLookupLocation,
118703
+ failedLookupLocationPath,
118704
+ rootDir,
118705
+ rootPath,
118706
+ rootSplitLength,
118707
+ getCurrentDirectory
118708
+ );
118673
118709
  if (toWatch) {
118674
118710
  const { dirPath } = toWatch;
118675
118711
  const refCount = customFailedLookupPaths.get(failedLookupLocationPath);
@@ -118837,13 +118873,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118837
118873
  function closeTypeRootsWatch() {
118838
118874
  clearMap(typeRootsWatches, closeFileWatcher);
118839
118875
  }
118840
- function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
118841
- if (isInDirectoryPath(rootPath, typeRootPath)) {
118842
- return rootPath;
118843
- }
118844
- const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
118845
- return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
118846
- }
118847
118876
  function createTypeRootsWatch(typeRootPath, typeRoot) {
118848
118877
  return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
118849
118878
  const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
@@ -118852,7 +118881,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118852
118881
  }
118853
118882
  hasChangedAutomaticTypeDirectiveNames = true;
118854
118883
  resolutionHost.onChangedAutomaticTypeDirectiveNames();
118855
- const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
118884
+ const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
118885
+ typeRoot,
118886
+ typeRootPath,
118887
+ rootPath,
118888
+ (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2)
118889
+ );
118856
118890
  if (dirPath) {
118857
118891
  scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
118858
118892
  }
@@ -118878,12 +118912,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118878
118912
  closeTypeRootsWatch();
118879
118913
  }
118880
118914
  }
118881
- function canWatchTypeRootPath(nodeTypesDirectory) {
118915
+ function canWatchTypeRootPath(typeRoot) {
118882
118916
  if (resolutionHost.getCompilationSettings().typeRoots)
118883
118917
  return true;
118884
- const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
118885
- const dirPath = resolutionHost.toPath(dir);
118886
- return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
118918
+ return canWatchAtTypes(resolutionHost.toPath(typeRoot), rootPath);
118887
118919
  }
118888
118920
  }
118889
118921
  function resolutionIsSymlink(resolution) {