typescript 5.0.0-dev.20221206 → 5.0.0-dev.20221207

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
@@ -23,7 +23,7 @@ var __export = (target, all) => {
23
23
 
24
24
  // src/compiler/corePublic.ts
25
25
  var versionMajorMinor = "5.0";
26
- var version = `${versionMajorMinor}.0-dev.20221206`;
26
+ var version = `${versionMajorMinor}.0-dev.20221207`;
27
27
 
28
28
  // src/compiler/core.ts
29
29
  var emptyArray = [];
@@ -1695,22 +1695,8 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
1695
1695
  function enableDebugInfo() {
1696
1696
  if (isDebugInfoEnabled)
1697
1697
  return;
1698
- let weakTypeTextMap;
1699
- let weakNodeTextMap;
1700
- function getWeakTypeTextMap() {
1701
- if (weakTypeTextMap === void 0) {
1702
- if (typeof WeakMap === "function")
1703
- weakTypeTextMap = /* @__PURE__ */ new WeakMap();
1704
- }
1705
- return weakTypeTextMap;
1706
- }
1707
- function getWeakNodeTextMap() {
1708
- if (weakNodeTextMap === void 0) {
1709
- if (typeof WeakMap === "function")
1710
- weakNodeTextMap = /* @__PURE__ */ new WeakMap();
1711
- }
1712
- return weakNodeTextMap;
1713
- }
1698
+ const weakTypeTextMap = /* @__PURE__ */ new WeakMap();
1699
+ const weakNodeTextMap = /* @__PURE__ */ new WeakMap();
1714
1700
  Object.defineProperties(objectAllocator.getSymbolConstructor().prototype, {
1715
1701
  __tsDebuggerDisplay: {
1716
1702
  value() {
@@ -1739,11 +1725,10 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
1739
1725
  } },
1740
1726
  __debugTypeToString: {
1741
1727
  value() {
1742
- const map2 = getWeakTypeTextMap();
1743
- let text = map2 == null ? void 0 : map2.get(this);
1728
+ let text = weakTypeTextMap.get(this);
1744
1729
  if (text === void 0) {
1745
1730
  text = this.checker.typeToString(this);
1746
- map2 == null ? void 0 : map2.set(this, text);
1731
+ weakTypeTextMap.set(this, text);
1747
1732
  }
1748
1733
  return text;
1749
1734
  }
@@ -1795,13 +1780,12 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
1795
1780
  value(includeTrivia) {
1796
1781
  if (nodeIsSynthesized(this))
1797
1782
  return "";
1798
- const map2 = getWeakNodeTextMap();
1799
- let text = map2 == null ? void 0 : map2.get(this);
1783
+ let text = weakNodeTextMap.get(this);
1800
1784
  if (text === void 0) {
1801
1785
  const parseNode = getParseTreeNode(this);
1802
1786
  const sourceFile = parseNode && getSourceFileOfNode(parseNode);
1803
1787
  text = sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
1804
- map2 == null ? void 0 : map2.set(this, text);
1788
+ weakNodeTextMap.set(this, text);
1805
1789
  }
1806
1790
  return text;
1807
1791
  }
@@ -32876,8 +32860,10 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
32876
32860
  options = redirectedReference.commandLine.options;
32877
32861
  }
32878
32862
  const containingDirectory = containingFile ? getDirectoryPath(containingFile) : void 0;
32879
- const perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : void 0;
32880
- let result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, resolutionMode);
32863
+ let result = containingDirectory ? cache == null ? void 0 : cache.getFromDirectoryCache(typeReferenceDirectiveName, resolutionMode, containingDirectory, redirectedReference) : void 0;
32864
+ if (!result && containingDirectory && !isExternalModuleNameRelative(typeReferenceDirectiveName)) {
32865
+ result = cache == null ? void 0 : cache.getFromNonRelativeNameCache(typeReferenceDirectiveName, resolutionMode, containingDirectory, redirectedReference);
32866
+ }
32881
32867
  if (result) {
32882
32868
  if (traceEnabled) {
32883
32869
  trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -32953,7 +32939,12 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
32953
32939
  affectingLocations: initializeResolutionField(affectingLocations),
32954
32940
  resolutionDiagnostics: initializeResolutionField(diagnostics)
32955
32941
  };
32956
- perFolderCache == null ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
32942
+ if (containingDirectory) {
32943
+ cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, resolutionMode, result);
32944
+ if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
32945
+ cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result);
32946
+ }
32947
+ }
32957
32948
  if (traceEnabled)
32958
32949
  traceResult(result);
32959
32950
  return result;
@@ -33073,23 +33064,27 @@ function createCacheWithRedirects(ownOptions) {
33073
33064
  if (ownOptions)
33074
33065
  redirectsMap.set(ownOptions, ownMap);
33075
33066
  return {
33067
+ getMapOfCacheRedirects,
33076
33068
  getOrCreateMapOfCacheRedirects,
33077
33069
  update,
33078
33070
  clear: clear2
33079
33071
  };
33072
+ function getMapOfCacheRedirects(redirectedReference) {
33073
+ return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options, false) : ownMap;
33074
+ }
33080
33075
  function getOrCreateMapOfCacheRedirects(redirectedReference) {
33081
- return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options) : ownMap;
33076
+ return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options, true) : ownMap;
33082
33077
  }
33083
33078
  function update(newOptions) {
33084
33079
  if (ownOptions !== newOptions) {
33085
33080
  if (ownOptions)
33086
- ownMap = getOrCreateMap(newOptions);
33081
+ ownMap = getOrCreateMap(newOptions, true);
33087
33082
  else
33088
33083
  redirectsMap.set(newOptions, ownMap);
33089
33084
  ownOptions = newOptions;
33090
33085
  }
33091
33086
  }
33092
- function getOrCreateMap(redirectOptions) {
33087
+ function getOrCreateMap(redirectOptions, create) {
33093
33088
  let result = redirectsMap.get(redirectOptions);
33094
33089
  if (result)
33095
33090
  return result;
@@ -33103,9 +33098,13 @@ function createCacheWithRedirects(ownOptions) {
33103
33098
  else if (!redirectsKeyToMap.has(ownKey))
33104
33099
  redirectsKeyToMap.set(ownKey, ownMap);
33105
33100
  }
33106
- redirectsKeyToMap.set(key, result != null ? result : result = /* @__PURE__ */ new Map());
33101
+ if (create)
33102
+ result != null ? result : result = /* @__PURE__ */ new Map();
33103
+ if (result)
33104
+ redirectsKeyToMap.set(key, result);
33107
33105
  }
33108
- redirectsMap.set(redirectOptions, result);
33106
+ if (result)
33107
+ redirectsMap.set(redirectOptions, result);
33109
33108
  return result;
33110
33109
  }
33111
33110
  function clear2() {
@@ -33157,8 +33156,10 @@ function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create)
33157
33156
  }
33158
33157
  return result;
33159
33158
  }
33160
- function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
33159
+ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options) {
33160
+ const directoryToModuleNameMap = createCacheWithRedirects(options);
33161
33161
  return {
33162
+ getFromDirectoryCache,
33162
33163
  getOrCreateCacheForDirectory,
33163
33164
  clear: clear2,
33164
33165
  update
@@ -33166,13 +33167,18 @@ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileNam
33166
33167
  function clear2() {
33167
33168
  directoryToModuleNameMap.clear();
33168
33169
  }
33169
- function update(options) {
33170
- directoryToModuleNameMap.update(options);
33170
+ function update(options2) {
33171
+ directoryToModuleNameMap.update(options2);
33171
33172
  }
33172
33173
  function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
33173
33174
  const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
33174
33175
  return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, () => createModeAwareCache());
33175
33176
  }
33177
+ function getFromDirectoryCache(name, mode, directoryName, redirectedReference) {
33178
+ var _a2, _b;
33179
+ const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
33180
+ return (_b = (_a2 = directoryToModuleNameMap.getMapOfCacheRedirects(redirectedReference)) == null ? void 0 : _a2.get(path)) == null ? void 0 : _b.get(name, mode);
33181
+ }
33176
33182
  }
33177
33183
  function createModeAwareCacheKey(specifier, mode) {
33178
33184
  return mode === void 0 ? specifier : `${mode}|${specifier}`;
@@ -33221,33 +33227,32 @@ function zipToModeAwareCache(file, keys, values, nameAndModeGetter) {
33221
33227
  }
33222
33228
  return map2;
33223
33229
  }
33224
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
33225
- const directoryToModuleNameMap = createCacheWithRedirects(options);
33226
- const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
33230
+ function getOriginalOrResolvedModuleFileName(result) {
33231
+ return result.resolvedModule && (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
33232
+ }
33233
+ function getOriginalOrResolvedTypeReferenceFileName(result) {
33234
+ return result.resolvedTypeReferenceDirective && (result.resolvedTypeReferenceDirective.originalPath || result.resolvedTypeReferenceDirective.resolvedFileName);
33235
+ }
33236
+ function createNonRelativeNameResolutionCache(currentDirectory, getCanonicalFileName, options, getResolvedFileName) {
33227
33237
  const moduleNameToDirectoryMap = createCacheWithRedirects(options);
33228
- const packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
33229
33238
  return {
33230
- ...packageJsonInfoCache,
33231
- ...perDirectoryResolutionCache,
33232
- getOrCreateCacheForModuleName,
33239
+ getFromNonRelativeNameCache,
33240
+ getOrCreateCacheForNonRelativeName,
33233
33241
  clear: clear2,
33234
- update,
33235
- getPackageJsonInfoCache: () => packageJsonInfoCache,
33236
- clearAllExceptPackageJsonInfoCache
33242
+ update
33237
33243
  };
33238
33244
  function clear2() {
33239
- clearAllExceptPackageJsonInfoCache();
33240
- packageJsonInfoCache.clear();
33241
- }
33242
- function clearAllExceptPackageJsonInfoCache() {
33243
- perDirectoryResolutionCache.clear();
33244
33245
  moduleNameToDirectoryMap.clear();
33245
33246
  }
33246
33247
  function update(options2) {
33247
- directoryToModuleNameMap.update(options2);
33248
33248
  moduleNameToDirectoryMap.update(options2);
33249
33249
  }
33250
- function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
33250
+ function getFromNonRelativeNameCache(nonRelativeModuleName, mode, directoryName, redirectedReference) {
33251
+ var _a2, _b;
33252
+ Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
33253
+ return (_b = (_a2 = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) == null ? void 0 : _a2.get(createModeAwareCacheKey(nonRelativeModuleName, mode))) == null ? void 0 : _b.get(directoryName);
33254
+ }
33255
+ function getOrCreateCacheForNonRelativeName(nonRelativeModuleName, mode, redirectedReference) {
33251
33256
  Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
33252
33257
  return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, createModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
33253
33258
  }
@@ -33263,7 +33268,7 @@ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, opt
33263
33268
  return;
33264
33269
  }
33265
33270
  directoryPathMap.set(path, result);
33266
- const resolvedFileName = result.resolvedModule && (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
33271
+ const resolvedFileName = getResolvedFileName(result);
33267
33272
  const commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
33268
33273
  let current = path;
33269
33274
  while (current !== commonPrefix) {
@@ -33297,14 +33302,22 @@ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, opt
33297
33302
  }
33298
33303
  }
33299
33304
  }
33300
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
33301
- const directoryToModuleNameMap = createCacheWithRedirects(options);
33302
- const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
33303
- packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
33305
+ function createModuleOrTypeReferenceResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, getResolvedFileName) {
33306
+ const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
33307
+ const nonRelativeNameResolutionCache = createNonRelativeNameResolutionCache(
33308
+ currentDirectory,
33309
+ getCanonicalFileName,
33310
+ options,
33311
+ getResolvedFileName
33312
+ );
33313
+ packageJsonInfoCache != null ? packageJsonInfoCache : packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
33304
33314
  return {
33305
33315
  ...packageJsonInfoCache,
33306
33316
  ...perDirectoryResolutionCache,
33317
+ ...nonRelativeNameResolutionCache,
33307
33318
  clear: clear2,
33319
+ update,
33320
+ getPackageJsonInfoCache: () => packageJsonInfoCache,
33308
33321
  clearAllExceptPackageJsonInfoCache
33309
33322
  };
33310
33323
  function clear2() {
@@ -33313,8 +33326,33 @@ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanoni
33313
33326
  }
33314
33327
  function clearAllExceptPackageJsonInfoCache() {
33315
33328
  perDirectoryResolutionCache.clear();
33329
+ nonRelativeNameResolutionCache.clear();
33330
+ }
33331
+ function update(options2) {
33332
+ perDirectoryResolutionCache.update(options2);
33333
+ nonRelativeNameResolutionCache.update(options2);
33316
33334
  }
33317
33335
  }
33336
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
33337
+ const result = createModuleOrTypeReferenceResolutionCache(
33338
+ currentDirectory,
33339
+ getCanonicalFileName,
33340
+ options,
33341
+ void 0,
33342
+ getOriginalOrResolvedModuleFileName
33343
+ );
33344
+ result.getOrCreateCacheForModuleName = (nonRelativeName, mode, redirectedReference) => result.getOrCreateCacheForNonRelativeName(nonRelativeName, mode, redirectedReference);
33345
+ return result;
33346
+ }
33347
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
33348
+ return createModuleOrTypeReferenceResolutionCache(
33349
+ currentDirectory,
33350
+ getCanonicalFileName,
33351
+ options,
33352
+ packageJsonInfoCache,
33353
+ getOriginalOrResolvedTypeReferenceFileName
33354
+ );
33355
+ }
33318
33356
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
33319
33357
  const traceEnabled = isTraceEnabled(compilerOptions, host);
33320
33358
  if (redirectedReference) {
@@ -33327,8 +33365,7 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
33327
33365
  }
33328
33366
  }
33329
33367
  const containingDirectory = getDirectoryPath(containingFile);
33330
- const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
33331
- let result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
33368
+ let result = cache == null ? void 0 : cache.getFromDirectoryCache(moduleName, resolutionMode, containingDirectory, redirectedReference);
33332
33369
  if (result) {
33333
33370
  if (traceEnabled) {
33334
33371
  trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -33378,11 +33415,9 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
33378
33415
  if (result && result.resolvedModule)
33379
33416
  perfLogger.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`);
33380
33417
  perfLogger.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null");
33381
- if (perFolderCache) {
33382
- perFolderCache.set(moduleName, resolutionMode, result);
33383
- if (!isExternalModuleNameRelative(moduleName)) {
33384
- cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
33385
- }
33418
+ cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
33419
+ if (!isExternalModuleNameRelative(moduleName)) {
33420
+ cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
33386
33421
  }
33387
33422
  }
33388
33423
  if (traceEnabled) {
@@ -34292,7 +34327,7 @@ function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directo
34292
34327
  return loadModuleFromNearestNodeModulesDirectoryWorker(4 /* Declaration */, moduleName, directory, state, true, void 0, void 0);
34293
34328
  }
34294
34329
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
34295
- const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? void 0 : state.features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */, redirectedReference);
34330
+ const mode = state.features === 0 ? void 0 : state.features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */;
34296
34331
  const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
34297
34332
  const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
34298
34333
  if (priorityExtensions) {
@@ -34306,7 +34341,7 @@ function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName,
34306
34341
  function lookup(extensions2) {
34307
34342
  return forEachAncestorDirectory(normalizeSlashes(directory), (ancestorDirectory) => {
34308
34343
  if (getBaseFileName(ancestorDirectory) !== "node_modules") {
34309
- const resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
34344
+ const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
34310
34345
  if (resolutionFromCache) {
34311
34346
  return resolutionFromCache;
34312
34347
  }
@@ -34452,8 +34487,8 @@ function getPackageNameFromTypesPackageName(mangledName) {
34452
34487
  function unmangleScopedPackageName(typesPackageName) {
34453
34488
  return stringContains(typesPackageName, mangledScopedPackageSeparator) ? "@" + typesPackageName.replace(mangledScopedPackageSeparator, directorySeparator) : typesPackageName;
34454
34489
  }
34455
- function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
34456
- const result = cache && cache.get(containingDirectory);
34490
+ function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
34491
+ const result = cache && cache.getFromNonRelativeNameCache(moduleName, mode, containingDirectory, redirectedReference);
34457
34492
  if (result) {
34458
34493
  if (state.traceEnabled) {
34459
34494
  trace(state.host, Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -34496,9 +34531,8 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
34496
34531
  return { value: resolvedUsingSettings };
34497
34532
  }
34498
34533
  if (!isExternalModuleNameRelative(moduleName)) {
34499
- const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, void 0, redirectedReference);
34500
34534
  const resolved2 = forEachAncestorDirectory(containingDirectory, (directory) => {
34501
- const resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, state);
34535
+ const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, void 0, directory, redirectedReference, state);
34502
34536
  if (resolutionFromCache) {
34503
34537
  return resolutionFromCache;
34504
34538
  }
@@ -37839,7 +37873,7 @@ function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory,
37839
37873
  if (!shortest) {
37840
37874
  return void 0;
37841
37875
  }
37842
- return getEmitModuleResolutionKind(compilerOptions) === 2 /* NodeJs */ ? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions) : removeFileExtension(shortest);
37876
+ return getEmitModuleResolutionKind(compilerOptions) === 1 /* Classic */ ? removeFileExtension(shortest) : removeExtensionAndIndexPostFix(shortest, ending, compilerOptions);
37843
37877
  }
37844
37878
  function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, sourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
37845
37879
  if (!host.fileExists || !host.readFile) {
@@ -67981,7 +68015,6 @@ function createTypeChecker(host) {
67981
68015
  let firstDefaultClause;
67982
68016
  let hasDuplicateDefaultClause = false;
67983
68017
  const expressionType = checkExpression(node.expression);
67984
- const expressionIsLiteral = isLiteralType(expressionType);
67985
68018
  forEach(node.caseBlock.clauses, (clause) => {
67986
68019
  if (clause.kind === 293 /* DefaultClause */ && !hasDuplicateDefaultClause) {
67987
68020
  if (firstDefaultClause === void 0) {
@@ -68000,15 +68033,9 @@ function createTypeChecker(host) {
68000
68033
  }
68001
68034
  function createLazyCaseClauseDiagnostics(clause2) {
68002
68035
  return () => {
68003
- let caseType = checkExpression(clause2.expression);
68004
- const caseIsLiteral = isLiteralType(caseType);
68005
- let comparedExpressionType = expressionType;
68006
- if (!caseIsLiteral || !expressionIsLiteral) {
68007
- caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
68008
- comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
68009
- }
68010
- if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
68011
- checkTypeComparableTo(caseType, comparedExpressionType, clause2.expression, void 0);
68036
+ const caseType = checkExpression(clause2.expression);
68037
+ if (!isTypeEqualityComparableTo(expressionType, caseType)) {
68038
+ checkTypeComparableTo(caseType, expressionType, clause2.expression, void 0);
68012
68039
  }
68013
68040
  };
68014
68041
  }
@@ -98057,7 +98084,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98057
98084
  const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
98058
98085
  const containingDir = getDirectoryPath(containingFileName);
98059
98086
  const redirectedReference = getRedirectReferenceForResolution(containingFile);
98060
- const fromCache = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir);
98087
+ const fromCache = moduleResolutionCache.getFromNonRelativeNameCache(name, mode, containingDir, redirectedReference);
98061
98088
  if (fromCache)
98062
98089
  addResolutionDiagnostics(fromCache);
98063
98090
  }
@@ -100654,6 +100681,26 @@ var BuilderState;
100654
100681
  (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = /* @__PURE__ */ new Set())).add(path);
100655
100682
  }
100656
100683
  BuilderState2.updateSignatureOfFile = updateSignatureOfFile;
100684
+ function computeDtsSignature(programOfThisState, sourceFile, cancellationToken, host, onNewSignature) {
100685
+ programOfThisState.emit(
100686
+ sourceFile,
100687
+ (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) => {
100688
+ Debug.assert(isDeclarationFileName(fileName), `File extension for signature expected to be dts: Got:: ${fileName}`);
100689
+ onNewSignature(computeSignatureWithDiagnostics(
100690
+ programOfThisState,
100691
+ sourceFile,
100692
+ text,
100693
+ host,
100694
+ data
100695
+ ), sourceFiles);
100696
+ },
100697
+ cancellationToken,
100698
+ true,
100699
+ void 0,
100700
+ true
100701
+ );
100702
+ }
100703
+ BuilderState2.computeDtsSignature = computeDtsSignature;
100657
100704
  function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature = state.useFileVersionAsSignature) {
100658
100705
  var _a2;
100659
100706
  if ((_a2 = state.hasCalledUpdateShapeSignature) == null ? void 0 : _a2.has(sourceFile.resolvedPath))
@@ -100662,26 +100709,12 @@ var BuilderState;
100662
100709
  const prevSignature = info.signature;
100663
100710
  let latestSignature;
100664
100711
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
100665
- programOfThisState.emit(
100666
- sourceFile,
100667
- (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) => {
100668
- Debug.assert(isDeclarationFileName(fileName), `File extension for signature expected to be dts: Got:: ${fileName}`);
100669
- latestSignature = computeSignatureWithDiagnostics(
100670
- programOfThisState,
100671
- sourceFile,
100672
- text,
100673
- host,
100674
- data
100675
- );
100676
- if (latestSignature !== prevSignature) {
100677
- updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
100678
- }
100679
- },
100680
- cancellationToken,
100681
- true,
100682
- void 0,
100683
- true
100684
- );
100712
+ computeDtsSignature(programOfThisState, sourceFile, cancellationToken, host, (signature, sourceFiles) => {
100713
+ latestSignature = signature;
100714
+ if (latestSignature !== prevSignature) {
100715
+ updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
100716
+ }
100717
+ });
100685
100718
  }
100686
100719
  if (latestSignature === void 0) {
100687
100720
  latestSignature = sourceFile.version;
@@ -100705,27 +100738,24 @@ var BuilderState;
100705
100738
  if (!state.exportedModulesMap)
100706
100739
  return;
100707
100740
  (state.oldExportedModulesMap || (state.oldExportedModulesMap = /* @__PURE__ */ new Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
100708
- if (!exportedModulesFromDeclarationEmit) {
100709
- state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
100710
- return;
100711
- }
100712
- let exportedModules;
100713
- exportedModulesFromDeclarationEmit.forEach((symbol) => addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)));
100741
+ const exportedModules = getExportedModules(exportedModulesFromDeclarationEmit);
100714
100742
  if (exportedModules) {
100715
100743
  state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
100716
100744
  } else {
100717
100745
  state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
100718
100746
  }
100719
- function addExportedModule(exportedModulePaths) {
100720
- if (exportedModulePaths == null ? void 0 : exportedModulePaths.length) {
100721
- if (!exportedModules) {
100722
- exportedModules = /* @__PURE__ */ new Set();
100723
- }
100724
- exportedModulePaths.forEach((path) => exportedModules.add(path));
100725
- }
100726
- }
100727
100747
  }
100728
100748
  BuilderState2.updateExportedModules = updateExportedModules;
100749
+ function getExportedModules(exportedModulesFromDeclarationEmit) {
100750
+ let exportedModules;
100751
+ exportedModulesFromDeclarationEmit == null ? void 0 : exportedModulesFromDeclarationEmit.forEach(
100752
+ (symbol) => getReferencedFilesFromImportedModuleSymbol(symbol).forEach(
100753
+ (path) => (exportedModules != null ? exportedModules : exportedModules = /* @__PURE__ */ new Set()).add(path)
100754
+ )
100755
+ );
100756
+ return exportedModules;
100757
+ }
100758
+ BuilderState2.getExportedModules = getExportedModules;
100729
100759
  function getAllDependencies(state, programOfThisState, sourceFile) {
100730
100760
  const compilerOptions = programOfThisState.getCompilerOptions();
100731
100761
  if (outFile(compilerOptions)) {
@@ -100867,9 +100897,9 @@ function getPendingEmitKind(optionsOrEmitKind, oldOptionsOrEmitKind) {
100867
100897
  function hasSameKeys(map1, map2) {
100868
100898
  return map1 === map2 || map1 !== void 0 && map2 !== void 0 && map1.size === map2.size && !forEachKey(map1, (key) => !map2.has(key));
100869
100899
  }
100870
- function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
100900
+ function createBuilderProgramState(newProgram, oldState) {
100871
100901
  var _a2, _b;
100872
- const state = BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
100902
+ const state = BuilderState.create(newProgram, oldState, false);
100873
100903
  state.program = newProgram;
100874
100904
  const compilerOptions = newProgram.getCompilerOptions();
100875
100905
  state.compilerOptions = compilerOptions;
@@ -101161,7 +101191,7 @@ function handleDtsMayChangeOf(state, path, cancellationToken, host) {
101161
101191
  sourceFile,
101162
101192
  cancellationToken,
101163
101193
  host,
101164
- !host.disableUseFileVersionAsSignature
101194
+ true
101165
101195
  );
101166
101196
  if (getEmitDeclarations(state.compilerOptions)) {
101167
101197
  addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
@@ -101544,7 +101574,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101544
101574
  oldState = void 0;
101545
101575
  return oldProgram;
101546
101576
  }
101547
- const state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
101577
+ const state = createBuilderProgramState(newProgram, oldState);
101548
101578
  newProgram.getBuildInfo = (bundle) => getBuildInfo2(state, bundle);
101549
101579
  newProgram = void 0;
101550
101580
  oldProgram = void 0;
@@ -102003,9 +102033,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102003
102033
  let filesWithInvalidatedResolutions;
102004
102034
  let filesWithInvalidatedNonRelativeUnresolvedImports;
102005
102035
  const nonRelativeExternalModuleResolutions = createMultiMap();
102006
- const resolutionsWithFailedLookups = [];
102007
- const resolutionsWithOnlyAffectingLocations = [];
102008
- const resolvedFileToResolution = createMultiMap();
102036
+ const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
102037
+ const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
102038
+ const resolvedFileToResolution = /* @__PURE__ */ new Map();
102009
102039
  const impliedFormatPackageJsons = /* @__PURE__ */ new Map();
102010
102040
  let hasChangedAutomaticTypeDirectiveNames = false;
102011
102041
  let affectingPathChecksForFile;
@@ -102078,8 +102108,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102078
102108
  resolvedModuleNames.clear();
102079
102109
  resolvedTypeReferenceDirectives.clear();
102080
102110
  resolvedFileToResolution.clear();
102081
- resolutionsWithFailedLookups.length = 0;
102082
- resolutionsWithOnlyAffectingLocations.length = 0;
102111
+ resolutionsWithFailedLookups.clear();
102112
+ resolutionsWithOnlyAffectingLocations.clear();
102083
102113
  failedLookupChecks = void 0;
102084
102114
  startsWithPathChecks = void 0;
102085
102115
  isInDirectoryChecks = void 0;
@@ -102396,12 +102426,13 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102396
102426
  return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
102397
102427
  }
102398
102428
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
102429
+ var _a2, _b;
102399
102430
  if (resolution.refCount) {
102400
102431
  resolution.refCount++;
102401
102432
  Debug.assertIsDefined(resolution.files);
102402
102433
  } else {
102403
102434
  resolution.refCount = 1;
102404
- Debug.assert(length(resolution.files) === 0);
102435
+ Debug.assert(!((_a2 = resolution.files) == null ? void 0 : _a2.size));
102405
102436
  if (isExternalModuleNameRelative(name)) {
102406
102437
  watchFailedLookupLocationOfResolution(resolution);
102407
102438
  } else {
@@ -102409,10 +102440,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102409
102440
  }
102410
102441
  const resolved = getResolutionWithResolvedFileName(resolution);
102411
102442
  if (resolved && resolved.resolvedFileName) {
102412
- resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
102443
+ const key = resolutionHost.toPath(resolved.resolvedFileName);
102444
+ let resolutions = resolvedFileToResolution.get(key);
102445
+ if (!resolutions)
102446
+ resolvedFileToResolution.set(key, resolutions = /* @__PURE__ */ new Set());
102447
+ resolutions.add(resolution);
102413
102448
  }
102414
102449
  }
102415
- (resolution.files || (resolution.files = [])).push(filePath);
102450
+ ((_b = resolution.files) != null ? _b : resolution.files = /* @__PURE__ */ new Set()).add(filePath);
102416
102451
  }
102417
102452
  function watchFailedLookupLocationOfResolution(resolution) {
102418
102453
  Debug.assert(!!resolution.refCount);
@@ -102420,7 +102455,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102420
102455
  if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length))
102421
102456
  return;
102422
102457
  if (failedLookupLocations == null ? void 0 : failedLookupLocations.length)
102423
- resolutionsWithFailedLookups.push(resolution);
102458
+ resolutionsWithFailedLookups.add(resolution);
102424
102459
  let setAtRoot = false;
102425
102460
  if (failedLookupLocations) {
102426
102461
  for (const failedLookupLocation of failedLookupLocations) {
@@ -102452,7 +102487,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102452
102487
  if (!(affectingLocations == null ? void 0 : affectingLocations.length))
102453
102488
  return;
102454
102489
  if (addToResolutionsWithOnlyAffectingLocations)
102455
- resolutionsWithOnlyAffectingLocations.push(resolution);
102490
+ resolutionsWithOnlyAffectingLocations.add(resolution);
102456
102491
  for (const affectingLocation of affectingLocations) {
102457
102492
  createFileWatcherOfAffectingLocation(affectingLocation, true);
102458
102493
  }
@@ -102531,17 +102566,20 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102531
102566
  }
102532
102567
  }
102533
102568
  function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
102534
- unorderedRemoveItem(Debug.checkDefined(resolution.files), filePath);
102569
+ Debug.checkDefined(resolution.files).delete(filePath);
102535
102570
  resolution.refCount--;
102536
102571
  if (resolution.refCount) {
102537
102572
  return;
102538
102573
  }
102539
102574
  const resolved = getResolutionWithResolvedFileName(resolution);
102540
102575
  if (resolved && resolved.resolvedFileName) {
102541
- resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
102576
+ const key = resolutionHost.toPath(resolved.resolvedFileName);
102577
+ const resolutions = resolvedFileToResolution.get(key);
102578
+ if ((resolutions == null ? void 0 : resolutions.delete(resolution)) && !resolutions.size)
102579
+ resolvedFileToResolution.delete(key);
102542
102580
  }
102543
102581
  const { failedLookupLocations, affectingLocations } = resolution;
102544
- if (unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
102582
+ if (resolutionsWithFailedLookups.delete(resolution)) {
102545
102583
  let removeAtRoot = false;
102546
102584
  for (const failedLookupLocation of failedLookupLocations) {
102547
102585
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
@@ -102568,7 +102606,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102568
102606
  removeDirectoryWatcher(rootPath);
102569
102607
  }
102570
102608
  } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
102571
- unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
102609
+ resolutionsWithOnlyAffectingLocations.delete(resolution);
102572
102610
  }
102573
102611
  if (affectingLocations) {
102574
102612
  for (const affectingLocation of affectingLocations) {
@@ -102616,15 +102654,15 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102616
102654
  if (!resolutions)
102617
102655
  return false;
102618
102656
  let invalidated = false;
102619
- for (const resolution of resolutions) {
102657
+ resolutions.forEach((resolution) => {
102620
102658
  if (resolution.isInvalidated || !canInvalidate(resolution))
102621
- continue;
102659
+ return;
102622
102660
  resolution.isInvalidated = invalidated = true;
102623
102661
  for (const containingFilePath of Debug.checkDefined(resolution.files)) {
102624
102662
  (filesWithInvalidatedResolutions != null ? filesWithInvalidatedResolutions : filesWithInvalidatedResolutions = /* @__PURE__ */ new Set()).add(containingFilePath);
102625
102663
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile);
102626
102664
  }
102627
- }
102665
+ });
102628
102666
  return invalidated;
102629
102667
  }
102630
102668
  function invalidateResolutionOfFile(filePath) {
@@ -103214,7 +103252,6 @@ function createCompilerHostFromProgramHost(host, getCompilerOptions, directorySt
103214
103252
  getEnvironmentVariable: maybeBind(host, host.getEnvironmentVariable) || (() => ""),
103215
103253
  createHash: maybeBind(host, host.createHash),
103216
103254
  readDirectory: maybeBind(host, host.readDirectory),
103217
- disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
103218
103255
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit
103219
103256
  };
103220
103257
  return compilerHost;
@@ -103281,7 +103318,6 @@ function createProgramHost(system, createProgram2) {
103281
103318
  writeFile: (path, data, writeByteOrderMark) => system.writeFile(path, data, writeByteOrderMark),
103282
103319
  createHash: maybeBind(system, system.createHash),
103283
103320
  createProgram: createProgram2 || createEmitAndSemanticDiagnosticsBuilderProgram,
103284
- disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
103285
103321
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
103286
103322
  now: maybeBind(system, system.now)
103287
103323
  };
@@ -103383,7 +103419,6 @@ function readBuilderProgram(compilerOptions, host) {
103383
103419
  function createIncrementalCompilerHost(options, system = sys) {
103384
103420
  const host = createCompilerHostWorker(options, void 0, system);
103385
103421
  host.createHash = maybeBind(system, system.createHash);
103386
- host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
103387
103422
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
103388
103423
  setGetSourceFileAsHashVersioned(host);
103389
103424
  changeCompilerHostLikeToUseCache(host, (fileName) => toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName));