typescript 5.0.0-dev.20221206 → 5.0.0-dev.20221208

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/typescript.js CHANGED
@@ -42,7 +42,7 @@ var ts = (() => {
42
42
  "src/compiler/corePublic.ts"() {
43
43
  "use strict";
44
44
  versionMajorMinor = "5.0";
45
- version = `${versionMajorMinor}.0-dev.20221206`;
45
+ version = `${versionMajorMinor}.0-dev.20221208`;
46
46
  Comparison = /* @__PURE__ */ ((Comparison3) => {
47
47
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
48
48
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -2190,22 +2190,8 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
2190
2190
  function enableDebugInfo() {
2191
2191
  if (isDebugInfoEnabled)
2192
2192
  return;
2193
- let weakTypeTextMap;
2194
- let weakNodeTextMap;
2195
- function getWeakTypeTextMap() {
2196
- if (weakTypeTextMap === void 0) {
2197
- if (typeof WeakMap === "function")
2198
- weakTypeTextMap = /* @__PURE__ */ new WeakMap();
2199
- }
2200
- return weakTypeTextMap;
2201
- }
2202
- function getWeakNodeTextMap() {
2203
- if (weakNodeTextMap === void 0) {
2204
- if (typeof WeakMap === "function")
2205
- weakNodeTextMap = /* @__PURE__ */ new WeakMap();
2206
- }
2207
- return weakNodeTextMap;
2208
- }
2193
+ const weakTypeTextMap = /* @__PURE__ */ new WeakMap();
2194
+ const weakNodeTextMap = /* @__PURE__ */ new WeakMap();
2209
2195
  Object.defineProperties(objectAllocator.getSymbolConstructor().prototype, {
2210
2196
  __tsDebuggerDisplay: {
2211
2197
  value() {
@@ -2234,11 +2220,10 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
2234
2220
  } },
2235
2221
  __debugTypeToString: {
2236
2222
  value() {
2237
- const map2 = getWeakTypeTextMap();
2238
- let text = map2 == null ? void 0 : map2.get(this);
2223
+ let text = weakTypeTextMap.get(this);
2239
2224
  if (text === void 0) {
2240
2225
  text = this.checker.typeToString(this);
2241
- map2 == null ? void 0 : map2.set(this, text);
2226
+ weakTypeTextMap.set(this, text);
2242
2227
  }
2243
2228
  return text;
2244
2229
  }
@@ -2290,13 +2275,12 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
2290
2275
  value(includeTrivia) {
2291
2276
  if (nodeIsSynthesized(this))
2292
2277
  return "";
2293
- const map2 = getWeakNodeTextMap();
2294
- let text = map2 == null ? void 0 : map2.get(this);
2278
+ let text = weakNodeTextMap.get(this);
2295
2279
  if (text === void 0) {
2296
2280
  const parseNode = getParseTreeNode(this);
2297
2281
  const sourceFile = parseNode && getSourceFileOfNode(parseNode);
2298
2282
  text = sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
2299
- map2 == null ? void 0 : map2.set(this, text);
2283
+ weakNodeTextMap.set(this, text);
2300
2284
  }
2301
2285
  return text;
2302
2286
  }
@@ -35139,8 +35123,10 @@ ${lanes.join("\n")}
35139
35123
  options = redirectedReference.commandLine.options;
35140
35124
  }
35141
35125
  const containingDirectory = containingFile ? getDirectoryPath(containingFile) : void 0;
35142
- const perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : void 0;
35143
- let result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, resolutionMode);
35126
+ let result = containingDirectory ? cache == null ? void 0 : cache.getFromDirectoryCache(typeReferenceDirectiveName, resolutionMode, containingDirectory, redirectedReference) : void 0;
35127
+ if (!result && containingDirectory && !isExternalModuleNameRelative(typeReferenceDirectiveName)) {
35128
+ result = cache == null ? void 0 : cache.getFromNonRelativeNameCache(typeReferenceDirectiveName, resolutionMode, containingDirectory, redirectedReference);
35129
+ }
35144
35130
  if (result) {
35145
35131
  if (traceEnabled) {
35146
35132
  trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -35216,7 +35202,12 @@ ${lanes.join("\n")}
35216
35202
  affectingLocations: initializeResolutionField(affectingLocations),
35217
35203
  resolutionDiagnostics: initializeResolutionField(diagnostics)
35218
35204
  };
35219
- perFolderCache == null ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
35205
+ if (containingDirectory) {
35206
+ cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, resolutionMode, result);
35207
+ if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
35208
+ cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result);
35209
+ }
35210
+ }
35220
35211
  if (traceEnabled)
35221
35212
  traceResult(result);
35222
35213
  return result;
@@ -35346,23 +35337,27 @@ ${lanes.join("\n")}
35346
35337
  if (ownOptions)
35347
35338
  redirectsMap.set(ownOptions, ownMap);
35348
35339
  return {
35340
+ getMapOfCacheRedirects,
35349
35341
  getOrCreateMapOfCacheRedirects,
35350
35342
  update,
35351
35343
  clear: clear2
35352
35344
  };
35345
+ function getMapOfCacheRedirects(redirectedReference) {
35346
+ return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options, false) : ownMap;
35347
+ }
35353
35348
  function getOrCreateMapOfCacheRedirects(redirectedReference) {
35354
- return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options) : ownMap;
35349
+ return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options, true) : ownMap;
35355
35350
  }
35356
35351
  function update(newOptions) {
35357
35352
  if (ownOptions !== newOptions) {
35358
35353
  if (ownOptions)
35359
- ownMap = getOrCreateMap(newOptions);
35354
+ ownMap = getOrCreateMap(newOptions, true);
35360
35355
  else
35361
35356
  redirectsMap.set(newOptions, ownMap);
35362
35357
  ownOptions = newOptions;
35363
35358
  }
35364
35359
  }
35365
- function getOrCreateMap(redirectOptions) {
35360
+ function getOrCreateMap(redirectOptions, create) {
35366
35361
  let result = redirectsMap.get(redirectOptions);
35367
35362
  if (result)
35368
35363
  return result;
@@ -35376,9 +35371,13 @@ ${lanes.join("\n")}
35376
35371
  else if (!redirectsKeyToMap.has(ownKey))
35377
35372
  redirectsKeyToMap.set(ownKey, ownMap);
35378
35373
  }
35379
- redirectsKeyToMap.set(key, result != null ? result : result = /* @__PURE__ */ new Map());
35374
+ if (create)
35375
+ result != null ? result : result = /* @__PURE__ */ new Map();
35376
+ if (result)
35377
+ redirectsKeyToMap.set(key, result);
35380
35378
  }
35381
- redirectsMap.set(redirectOptions, result);
35379
+ if (result)
35380
+ redirectsMap.set(redirectOptions, result);
35382
35381
  return result;
35383
35382
  }
35384
35383
  function clear2() {
@@ -35430,8 +35429,10 @@ ${lanes.join("\n")}
35430
35429
  }
35431
35430
  return result;
35432
35431
  }
35433
- function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
35432
+ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options) {
35433
+ const directoryToModuleNameMap = createCacheWithRedirects(options);
35434
35434
  return {
35435
+ getFromDirectoryCache,
35435
35436
  getOrCreateCacheForDirectory,
35436
35437
  clear: clear2,
35437
35438
  update
@@ -35439,13 +35440,18 @@ ${lanes.join("\n")}
35439
35440
  function clear2() {
35440
35441
  directoryToModuleNameMap.clear();
35441
35442
  }
35442
- function update(options) {
35443
- directoryToModuleNameMap.update(options);
35443
+ function update(options2) {
35444
+ directoryToModuleNameMap.update(options2);
35444
35445
  }
35445
35446
  function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
35446
35447
  const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
35447
35448
  return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, () => createModeAwareCache());
35448
35449
  }
35450
+ function getFromDirectoryCache(name, mode, directoryName, redirectedReference) {
35451
+ var _a2, _b;
35452
+ const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
35453
+ return (_b = (_a2 = directoryToModuleNameMap.getMapOfCacheRedirects(redirectedReference)) == null ? void 0 : _a2.get(path)) == null ? void 0 : _b.get(name, mode);
35454
+ }
35449
35455
  }
35450
35456
  function createModeAwareCacheKey(specifier, mode) {
35451
35457
  return mode === void 0 ? specifier : `${mode}|${specifier}`;
@@ -35494,33 +35500,32 @@ ${lanes.join("\n")}
35494
35500
  }
35495
35501
  return map2;
35496
35502
  }
35497
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
35498
- const directoryToModuleNameMap = createCacheWithRedirects(options);
35499
- const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
35503
+ function getOriginalOrResolvedModuleFileName(result) {
35504
+ return result.resolvedModule && (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35505
+ }
35506
+ function getOriginalOrResolvedTypeReferenceFileName(result) {
35507
+ return result.resolvedTypeReferenceDirective && (result.resolvedTypeReferenceDirective.originalPath || result.resolvedTypeReferenceDirective.resolvedFileName);
35508
+ }
35509
+ function createNonRelativeNameResolutionCache(currentDirectory, getCanonicalFileName, options, getResolvedFileName) {
35500
35510
  const moduleNameToDirectoryMap = createCacheWithRedirects(options);
35501
- const packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
35502
35511
  return {
35503
- ...packageJsonInfoCache,
35504
- ...perDirectoryResolutionCache,
35505
- getOrCreateCacheForModuleName,
35512
+ getFromNonRelativeNameCache,
35513
+ getOrCreateCacheForNonRelativeName,
35506
35514
  clear: clear2,
35507
- update,
35508
- getPackageJsonInfoCache: () => packageJsonInfoCache,
35509
- clearAllExceptPackageJsonInfoCache
35515
+ update
35510
35516
  };
35511
35517
  function clear2() {
35512
- clearAllExceptPackageJsonInfoCache();
35513
- packageJsonInfoCache.clear();
35514
- }
35515
- function clearAllExceptPackageJsonInfoCache() {
35516
- perDirectoryResolutionCache.clear();
35517
35518
  moduleNameToDirectoryMap.clear();
35518
35519
  }
35519
35520
  function update(options2) {
35520
- directoryToModuleNameMap.update(options2);
35521
35521
  moduleNameToDirectoryMap.update(options2);
35522
35522
  }
35523
- function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
35523
+ function getFromNonRelativeNameCache(nonRelativeModuleName, mode, directoryName, redirectedReference) {
35524
+ var _a2, _b;
35525
+ Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
35526
+ return (_b = (_a2 = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) == null ? void 0 : _a2.get(createModeAwareCacheKey(nonRelativeModuleName, mode))) == null ? void 0 : _b.get(directoryName);
35527
+ }
35528
+ function getOrCreateCacheForNonRelativeName(nonRelativeModuleName, mode, redirectedReference) {
35524
35529
  Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
35525
35530
  return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, createModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
35526
35531
  }
@@ -35536,7 +35541,7 @@ ${lanes.join("\n")}
35536
35541
  return;
35537
35542
  }
35538
35543
  directoryPathMap.set(path, result);
35539
- const resolvedFileName = result.resolvedModule && (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35544
+ const resolvedFileName = getResolvedFileName(result);
35540
35545
  const commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
35541
35546
  let current = path;
35542
35547
  while (current !== commonPrefix) {
@@ -35570,14 +35575,22 @@ ${lanes.join("\n")}
35570
35575
  }
35571
35576
  }
35572
35577
  }
35573
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
35574
- const directoryToModuleNameMap = createCacheWithRedirects(options);
35575
- const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
35576
- packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
35578
+ function createModuleOrTypeReferenceResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, getResolvedFileName) {
35579
+ const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
35580
+ const nonRelativeNameResolutionCache = createNonRelativeNameResolutionCache(
35581
+ currentDirectory,
35582
+ getCanonicalFileName,
35583
+ options,
35584
+ getResolvedFileName
35585
+ );
35586
+ packageJsonInfoCache != null ? packageJsonInfoCache : packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
35577
35587
  return {
35578
35588
  ...packageJsonInfoCache,
35579
35589
  ...perDirectoryResolutionCache,
35590
+ ...nonRelativeNameResolutionCache,
35580
35591
  clear: clear2,
35592
+ update,
35593
+ getPackageJsonInfoCache: () => packageJsonInfoCache,
35581
35594
  clearAllExceptPackageJsonInfoCache
35582
35595
  };
35583
35596
  function clear2() {
@@ -35586,14 +35599,36 @@ ${lanes.join("\n")}
35586
35599
  }
35587
35600
  function clearAllExceptPackageJsonInfoCache() {
35588
35601
  perDirectoryResolutionCache.clear();
35602
+ nonRelativeNameResolutionCache.clear();
35589
35603
  }
35604
+ function update(options2) {
35605
+ perDirectoryResolutionCache.update(options2);
35606
+ nonRelativeNameResolutionCache.update(options2);
35607
+ }
35608
+ }
35609
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
35610
+ const result = createModuleOrTypeReferenceResolutionCache(
35611
+ currentDirectory,
35612
+ getCanonicalFileName,
35613
+ options,
35614
+ void 0,
35615
+ getOriginalOrResolvedModuleFileName
35616
+ );
35617
+ result.getOrCreateCacheForModuleName = (nonRelativeName, mode, redirectedReference) => result.getOrCreateCacheForNonRelativeName(nonRelativeName, mode, redirectedReference);
35618
+ return result;
35619
+ }
35620
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
35621
+ return createModuleOrTypeReferenceResolutionCache(
35622
+ currentDirectory,
35623
+ getCanonicalFileName,
35624
+ options,
35625
+ packageJsonInfoCache,
35626
+ getOriginalOrResolvedTypeReferenceFileName
35627
+ );
35590
35628
  }
35591
35629
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
35592
35630
  const containingDirectory = getDirectoryPath(containingFile);
35593
- const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
35594
- if (!perFolderCache)
35595
- return void 0;
35596
- return perFolderCache.get(moduleName, mode);
35631
+ return cache.getFromDirectoryCache(moduleName, mode, containingDirectory, void 0);
35597
35632
  }
35598
35633
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
35599
35634
  const traceEnabled = isTraceEnabled(compilerOptions, host);
@@ -35607,8 +35642,7 @@ ${lanes.join("\n")}
35607
35642
  }
35608
35643
  }
35609
35644
  const containingDirectory = getDirectoryPath(containingFile);
35610
- const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
35611
- let result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
35645
+ let result = cache == null ? void 0 : cache.getFromDirectoryCache(moduleName, resolutionMode, containingDirectory, redirectedReference);
35612
35646
  if (result) {
35613
35647
  if (traceEnabled) {
35614
35648
  trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -35658,11 +35692,9 @@ ${lanes.join("\n")}
35658
35692
  if (result && result.resolvedModule)
35659
35693
  perfLogger.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`);
35660
35694
  perfLogger.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null");
35661
- if (perFolderCache) {
35662
- perFolderCache.set(moduleName, resolutionMode, result);
35663
- if (!isExternalModuleNameRelative(moduleName)) {
35664
- cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
35665
- }
35695
+ cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
35696
+ if (!isExternalModuleNameRelative(moduleName)) {
35697
+ cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
35666
35698
  }
35667
35699
  }
35668
35700
  if (traceEnabled) {
@@ -36641,7 +36673,7 @@ ${lanes.join("\n")}
36641
36673
  return loadModuleFromNearestNodeModulesDirectoryWorker(4 /* Declaration */, moduleName, directory, state, true, void 0, void 0);
36642
36674
  }
36643
36675
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
36644
- const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? void 0 : state.features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */, redirectedReference);
36676
+ const mode = state.features === 0 ? void 0 : state.features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */;
36645
36677
  const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
36646
36678
  const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
36647
36679
  if (priorityExtensions) {
@@ -36655,7 +36687,7 @@ ${lanes.join("\n")}
36655
36687
  function lookup(extensions2) {
36656
36688
  return forEachAncestorDirectory(normalizeSlashes(directory), (ancestorDirectory) => {
36657
36689
  if (getBaseFileName(ancestorDirectory) !== "node_modules") {
36658
- const resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
36690
+ const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
36659
36691
  if (resolutionFromCache) {
36660
36692
  return resolutionFromCache;
36661
36693
  }
@@ -36800,8 +36832,8 @@ ${lanes.join("\n")}
36800
36832
  function unmangleScopedPackageName(typesPackageName) {
36801
36833
  return stringContains(typesPackageName, mangledScopedPackageSeparator) ? "@" + typesPackageName.replace(mangledScopedPackageSeparator, directorySeparator) : typesPackageName;
36802
36834
  }
36803
- function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
36804
- const result = cache && cache.get(containingDirectory);
36835
+ function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
36836
+ const result = cache && cache.getFromNonRelativeNameCache(moduleName, mode, containingDirectory, redirectedReference);
36805
36837
  if (result) {
36806
36838
  if (state.traceEnabled) {
36807
36839
  trace(state.host, Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -36844,9 +36876,8 @@ ${lanes.join("\n")}
36844
36876
  return { value: resolvedUsingSettings };
36845
36877
  }
36846
36878
  if (!isExternalModuleNameRelative(moduleName)) {
36847
- const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, void 0, redirectedReference);
36848
36879
  const resolved2 = forEachAncestorDirectory(containingDirectory, (directory) => {
36849
- const resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, state);
36880
+ const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, void 0, directory, redirectedReference, state);
36850
36881
  if (resolutionFromCache) {
36851
36882
  return resolutionFromCache;
36852
36883
  }
@@ -40258,7 +40289,7 @@ ${lanes.join("\n")}
40258
40289
  if (!shortest) {
40259
40290
  return void 0;
40260
40291
  }
40261
- return getEmitModuleResolutionKind(compilerOptions) === 2 /* NodeJs */ ? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions) : removeFileExtension(shortest);
40292
+ return getEmitModuleResolutionKind(compilerOptions) === 1 /* Classic */ ? removeFileExtension(shortest) : removeExtensionAndIndexPostFix(shortest, ending, compilerOptions);
40262
40293
  }
40263
40294
  function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, sourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
40264
40295
  if (!host.fileExists || !host.readFile) {
@@ -40934,8 +40965,9 @@ ${lanes.join("\n")}
40934
40965
  const nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown");
40935
40966
  const undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined");
40936
40967
  const undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */);
40968
+ const missingType = createIntrinsicType(32768 /* Undefined */, "undefined");
40969
+ const undefinedOrMissingType = exactOptionalPropertyTypes ? missingType : undefinedType;
40937
40970
  const optionalType = createIntrinsicType(32768 /* Undefined */, "undefined");
40938
- const missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType;
40939
40971
  const nullType = createIntrinsicType(65536 /* Null */, "null");
40940
40972
  const nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */);
40941
40973
  const stringType = createIntrinsicType(4 /* String */, "string");
@@ -51093,7 +51125,7 @@ ${lanes.join("\n")}
51093
51125
  return links.resolvedJSDocType;
51094
51126
  }
51095
51127
  function getSubstitutionType(baseType, constraint) {
51096
- if (constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || !isGenericType(baseType) && !isGenericType(constraint)) {
51128
+ if (constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType) {
51097
51129
  return baseType;
51098
51130
  }
51099
51131
  const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`;
@@ -51833,10 +51865,9 @@ ${lanes.join("\n")}
51833
51865
  if (includes & 3 /* AnyOrUnknown */) {
51834
51866
  return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType;
51835
51867
  }
51836
- if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) {
51837
- const missingIndex = binarySearch(typeSet, missingType, getTypeId, compareValues);
51838
- if (missingIndex >= 0 && containsType(typeSet, undefinedType)) {
51839
- orderedRemoveItemAt(typeSet, missingIndex);
51868
+ if (includes & 32768 /* Undefined */) {
51869
+ if (typeSet.length >= 2 && typeSet[0] === undefinedType && typeSet[1] === missingType) {
51870
+ orderedRemoveItemAt(typeSet, 1);
51840
51871
  }
51841
51872
  }
51842
51873
  if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) {
@@ -51961,7 +51992,7 @@ ${lanes.join("\n")}
51961
51992
  if (type === wildcardType)
51962
51993
  includes |= 8388608 /* IncludesWildcard */;
51963
51994
  } else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
51964
- if (exactOptionalPropertyTypes && type === missingType) {
51995
+ if (type === missingType) {
51965
51996
  includes |= 262144 /* IncludesMissingType */;
51966
51997
  type = undefinedType;
51967
51998
  }
@@ -52111,9 +52142,9 @@ ${lanes.join("\n")}
52111
52142
  if (intersectUnionsOfPrimitiveTypes(typeSet)) {
52112
52143
  result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
52113
52144
  } else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
52114
- const undefinedOrMissingType = exactOptionalPropertyTypes && some(typeSet, (t) => containsType(t.types, missingType)) ? missingType : undefinedType;
52145
+ const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
52115
52146
  removeFromEach(typeSet, 32768 /* Undefined */);
52116
- result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
52147
+ result = getUnionType([getIntersectionType(typeSet), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
52117
52148
  } else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
52118
52149
  removeFromEach(typeSet, 65536 /* Null */);
52119
52150
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
@@ -52532,7 +52563,7 @@ ${lanes.join("\n")}
52532
52563
  errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
52533
52564
  return mapType(objectType, (t) => {
52534
52565
  const restType = getRestTypeOfTupleType(t) || undefinedType;
52535
- return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType;
52566
+ return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, missingType]) : restType;
52536
52567
  });
52537
52568
  }
52538
52569
  }
@@ -52552,11 +52583,11 @@ ${lanes.join("\n")}
52552
52583
  if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
52553
52584
  const indexNode = getIndexNodeForAccessExpression(accessNode);
52554
52585
  error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
52555
- return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
52586
+ return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, missingType]) : indexInfo.type;
52556
52587
  }
52557
52588
  errorIfWritingToReadonlyIndex(indexInfo);
52558
52589
  if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags & 1024 /* EnumLiteral */ && getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
52559
- return getUnionType([indexInfo.type, undefinedType]);
52590
+ return getUnionType([indexInfo.type, missingType]);
52560
52591
  }
52561
52592
  return indexInfo.type;
52562
52593
  }
@@ -57017,8 +57048,8 @@ ${lanes.join("\n")}
57017
57048
  }
57018
57049
  function getOptionalType(type, isProperty = false) {
57019
57050
  Debug.assert(strictNullChecks);
57020
- const missingOrUndefined = isProperty ? missingType : undefinedType;
57021
- return type.flags & 32768 /* Undefined */ || type.flags & 1048576 /* Union */ && type.types[0] === missingOrUndefined ? type : getUnionType([type, missingOrUndefined]);
57051
+ const missingOrUndefined = isProperty ? undefinedOrMissingType : undefinedType;
57052
+ return type === missingOrUndefined || type.flags & 1048576 /* Union */ && type.types[0] === missingOrUndefined ? type : getUnionType([type, missingOrUndefined]);
57022
57053
  }
57023
57054
  function getGlobalNonNullableTypeInstantiation(type) {
57024
57055
  if (!deferredGlobalNonNullableTypeAlias) {
@@ -57045,7 +57076,7 @@ ${lanes.join("\n")}
57045
57076
  return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type;
57046
57077
  }
57047
57078
  function containsMissingType(type) {
57048
- return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType));
57079
+ return type === missingType || !!(type.flags & 1048576 /* Union */) && type.types[0] === missingType;
57049
57080
  }
57050
57081
  function removeMissingOrUndefinedType(type) {
57051
57082
  return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */);
@@ -57145,7 +57176,7 @@ ${lanes.join("\n")}
57145
57176
  if (cached) {
57146
57177
  return cached;
57147
57178
  }
57148
- const result = createSymbolWithType(prop, missingType);
57179
+ const result = createSymbolWithType(prop, undefinedOrMissingType);
57149
57180
  result.flags |= 16777216 /* Optional */;
57150
57181
  undefinedProperties.set(prop.escapedName, result);
57151
57182
  return result;
@@ -58195,7 +58226,7 @@ ${lanes.join("\n")}
58195
58226
  }
58196
58227
  }
58197
58228
  function isTypeOrBaseIdenticalTo(s, t) {
58198
- return exactOptionalPropertyTypes && t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */);
58229
+ return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */);
58199
58230
  }
58200
58231
  function isTypeCloselyMatchedBy(s, t) {
58201
58232
  return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
@@ -58724,7 +58755,7 @@ ${lanes.join("\n")}
58724
58755
  function includeUndefinedInIndexSignature(type) {
58725
58756
  if (!type)
58726
58757
  return type;
58727
- return compilerOptions.noUncheckedIndexedAccess ? getUnionType([type, undefinedType]) : type;
58758
+ return compilerOptions.noUncheckedIndexedAccess ? getUnionType([type, missingType]) : type;
58728
58759
  }
58729
58760
  function getTypeOfDestructuredSpreadExpression(type) {
58730
58761
  return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, void 0) || errorType);
@@ -59489,7 +59520,7 @@ ${lanes.join("\n")}
59489
59520
  if (bypassFlow) {
59490
59521
  const flowType = getTypeAtFlowNode(bypassFlow);
59491
59522
  const type = getTypeFromFlowType(flowType);
59492
- if (!contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
59523
+ if (!(type.flags & 131072 /* Never */) && !contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
59493
59524
  if (type === declaredType && declaredType === initialType) {
59494
59525
  return type;
59495
59526
  }
@@ -61628,7 +61659,7 @@ ${lanes.join("\n")}
61628
61659
  }
61629
61660
  } else if (exactOptionalPropertyTypes && e.kind === 229 /* OmittedExpression */) {
61630
61661
  hasOmittedExpression = true;
61631
- elementTypes.push(missingType);
61662
+ elementTypes.push(undefinedOrMissingType);
61632
61663
  elementFlags.push(2 /* Optional */);
61633
61664
  } else {
61634
61665
  const elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length);
@@ -62775,7 +62806,7 @@ ${lanes.join("\n")}
62775
62806
  if (indexInfo.isReadonly && (isAssignmentTarget(node) || isDeleteTarget(node))) {
62776
62807
  error(node, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType));
62777
62808
  }
62778
- propType = compilerOptions.noUncheckedIndexedAccess && !isAssignmentTarget(node) ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
62809
+ propType = compilerOptions.noUncheckedIndexedAccess && !isAssignmentTarget(node) ? getUnionType([indexInfo.type, missingType]) : indexInfo.type;
62779
62810
  if (compilerOptions.noPropertyAccessFromIndexSignature && isPropertyAccessExpression(node)) {
62780
62811
  error(right, Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, unescapeLeadingUnderscores(right.escapedText));
62781
62812
  }
@@ -64977,6 +65008,7 @@ ${lanes.join("\n")}
64977
65008
  }
64978
65009
  function checkExpressionWithTypeArguments(node) {
64979
65010
  checkGrammarExpressionWithTypeArguments(node);
65011
+ forEach(node.typeArguments, checkSourceElement);
64980
65012
  const exprType = node.kind === 230 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
64981
65013
  const typeArguments = node.typeArguments;
64982
65014
  if (exprType === silentNeverType || isErrorType(exprType) || !some(typeArguments)) {
@@ -70304,7 +70336,6 @@ ${lanes.join("\n")}
70304
70336
  let firstDefaultClause;
70305
70337
  let hasDuplicateDefaultClause = false;
70306
70338
  const expressionType = checkExpression(node.expression);
70307
- const expressionIsLiteral = isLiteralType(expressionType);
70308
70339
  forEach(node.caseBlock.clauses, (clause) => {
70309
70340
  if (clause.kind === 293 /* DefaultClause */ && !hasDuplicateDefaultClause) {
70310
70341
  if (firstDefaultClause === void 0) {
@@ -70323,15 +70354,9 @@ ${lanes.join("\n")}
70323
70354
  }
70324
70355
  function createLazyCaseClauseDiagnostics(clause2) {
70325
70356
  return () => {
70326
- let caseType = checkExpression(clause2.expression);
70327
- const caseIsLiteral = isLiteralType(caseType);
70328
- let comparedExpressionType = expressionType;
70329
- if (!caseIsLiteral || !expressionIsLiteral) {
70330
- caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
70331
- comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
70332
- }
70333
- if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
70334
- checkTypeComparableTo(caseType, comparedExpressionType, clause2.expression, void 0);
70357
+ const caseType = checkExpression(clause2.expression);
70358
+ if (!isTypeEqualityComparableTo(expressionType, caseType)) {
70359
+ checkTypeComparableTo(caseType, expressionType, clause2.expression, void 0);
70335
70360
  }
70336
70361
  };
70337
70362
  }
@@ -100769,6 +100794,7 @@ ${lanes.join("\n")}
100769
100794
  getSymlinkCache,
100770
100795
  realpath: (_o = host.realpath) == null ? void 0 : _o.bind(host),
100771
100796
  useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
100797
+ getCanonicalFileName,
100772
100798
  getFileIncludeReasons: () => fileReasons,
100773
100799
  structureIsReused,
100774
100800
  writeFile: writeFile2
@@ -100809,7 +100835,7 @@ ${lanes.join("\n")}
100809
100835
  const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
100810
100836
  const containingDir = getDirectoryPath(containingFileName);
100811
100837
  const redirectedReference = getRedirectReferenceForResolution(containingFile);
100812
- const fromCache = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir);
100838
+ const fromCache = moduleResolutionCache.getFromNonRelativeNameCache(name, mode, containingDir, redirectedReference);
100813
100839
  if (fromCache)
100814
100840
  addResolutionDiagnostics(fromCache);
100815
100841
  }
@@ -103485,14 +103511,13 @@ ${lanes.join("\n")}
103485
103511
  const referencedMap = options.module !== 0 /* None */ && !isOutFile ? createManyToManyPathMap() : void 0;
103486
103512
  const exportedModulesMap = referencedMap ? createManyToManyPathMap() : void 0;
103487
103513
  const useOldState = canReuseOldState(referencedMap, oldState);
103488
- const getCanonicalFileName = createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
103489
103514
  newProgram.getTypeChecker();
103490
103515
  for (const sourceFile of newProgram.getSourceFiles()) {
103491
103516
  const version2 = Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
103492
103517
  const oldUncommittedSignature = useOldState ? (_a2 = oldState.oldSignatures) == null ? void 0 : _a2.get(sourceFile.resolvedPath) : void 0;
103493
103518
  const signature = oldUncommittedSignature === void 0 ? useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) == null ? void 0 : _b.signature : void 0 : oldUncommittedSignature || void 0;
103494
103519
  if (referencedMap) {
103495
- const newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
103520
+ const newReferences = getReferencedFiles(newProgram, sourceFile, newProgram.getCanonicalFileName);
103496
103521
  if (newReferences) {
103497
103522
  referencedMap.set(sourceFile.resolvedPath, newReferences);
103498
103523
  }
@@ -103554,6 +103579,26 @@ ${lanes.join("\n")}
103554
103579
  (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = /* @__PURE__ */ new Set())).add(path);
103555
103580
  }
103556
103581
  BuilderState2.updateSignatureOfFile = updateSignatureOfFile;
103582
+ function computeDtsSignature(programOfThisState, sourceFile, cancellationToken, host, onNewSignature) {
103583
+ programOfThisState.emit(
103584
+ sourceFile,
103585
+ (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) => {
103586
+ Debug.assert(isDeclarationFileName(fileName), `File extension for signature expected to be dts: Got:: ${fileName}`);
103587
+ onNewSignature(computeSignatureWithDiagnostics(
103588
+ programOfThisState,
103589
+ sourceFile,
103590
+ text,
103591
+ host,
103592
+ data
103593
+ ), sourceFiles);
103594
+ },
103595
+ cancellationToken,
103596
+ true,
103597
+ void 0,
103598
+ true
103599
+ );
103600
+ }
103601
+ BuilderState2.computeDtsSignature = computeDtsSignature;
103557
103602
  function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature = state.useFileVersionAsSignature) {
103558
103603
  var _a2;
103559
103604
  if ((_a2 = state.hasCalledUpdateShapeSignature) == null ? void 0 : _a2.has(sourceFile.resolvedPath))
@@ -103562,26 +103607,12 @@ ${lanes.join("\n")}
103562
103607
  const prevSignature = info.signature;
103563
103608
  let latestSignature;
103564
103609
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
103565
- programOfThisState.emit(
103566
- sourceFile,
103567
- (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) => {
103568
- Debug.assert(isDeclarationFileName(fileName), `File extension for signature expected to be dts: Got:: ${fileName}`);
103569
- latestSignature = computeSignatureWithDiagnostics(
103570
- programOfThisState,
103571
- sourceFile,
103572
- text,
103573
- host,
103574
- data
103575
- );
103576
- if (latestSignature !== prevSignature) {
103577
- updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
103578
- }
103579
- },
103580
- cancellationToken,
103581
- true,
103582
- void 0,
103583
- true
103584
- );
103610
+ computeDtsSignature(programOfThisState, sourceFile, cancellationToken, host, (signature, sourceFiles) => {
103611
+ latestSignature = signature;
103612
+ if (latestSignature !== prevSignature) {
103613
+ updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
103614
+ }
103615
+ });
103585
103616
  }
103586
103617
  if (latestSignature === void 0) {
103587
103618
  latestSignature = sourceFile.version;
@@ -103605,27 +103636,24 @@ ${lanes.join("\n")}
103605
103636
  if (!state.exportedModulesMap)
103606
103637
  return;
103607
103638
  (state.oldExportedModulesMap || (state.oldExportedModulesMap = /* @__PURE__ */ new Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
103608
- if (!exportedModulesFromDeclarationEmit) {
103609
- state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
103610
- return;
103611
- }
103612
- let exportedModules;
103613
- exportedModulesFromDeclarationEmit.forEach((symbol) => addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)));
103639
+ const exportedModules = getExportedModules(exportedModulesFromDeclarationEmit);
103614
103640
  if (exportedModules) {
103615
103641
  state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
103616
103642
  } else {
103617
103643
  state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
103618
103644
  }
103619
- function addExportedModule(exportedModulePaths) {
103620
- if (exportedModulePaths == null ? void 0 : exportedModulePaths.length) {
103621
- if (!exportedModules) {
103622
- exportedModules = /* @__PURE__ */ new Set();
103623
- }
103624
- exportedModulePaths.forEach((path) => exportedModules.add(path));
103625
- }
103626
- }
103627
103645
  }
103628
103646
  BuilderState2.updateExportedModules = updateExportedModules;
103647
+ function getExportedModules(exportedModulesFromDeclarationEmit) {
103648
+ let exportedModules;
103649
+ exportedModulesFromDeclarationEmit == null ? void 0 : exportedModulesFromDeclarationEmit.forEach(
103650
+ (symbol) => getReferencedFilesFromImportedModuleSymbol(symbol).forEach(
103651
+ (path) => (exportedModules != null ? exportedModules : exportedModules = /* @__PURE__ */ new Set()).add(path)
103652
+ )
103653
+ );
103654
+ return exportedModules;
103655
+ }
103656
+ BuilderState2.getExportedModules = getExportedModules;
103629
103657
  function getAllDependencies(state, programOfThisState, sourceFile) {
103630
103658
  const compilerOptions = programOfThisState.getCompilerOptions();
103631
103659
  if (outFile(compilerOptions)) {
@@ -103769,9 +103797,9 @@ ${lanes.join("\n")}
103769
103797
  function hasSameKeys(map1, map2) {
103770
103798
  return map1 === map2 || map1 !== void 0 && map2 !== void 0 && map1.size === map2.size && !forEachKey(map1, (key) => !map2.has(key));
103771
103799
  }
103772
- function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
103800
+ function createBuilderProgramState(newProgram, oldState) {
103773
103801
  var _a2, _b;
103774
- const state = BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
103802
+ const state = BuilderState.create(newProgram, oldState, false);
103775
103803
  state.program = newProgram;
103776
103804
  const compilerOptions = newProgram.getCompilerOptions();
103777
103805
  state.compilerOptions = compilerOptions;
@@ -103879,7 +103907,6 @@ ${lanes.join("\n")}
103879
103907
  if (!diagnostics.length)
103880
103908
  return emptyArray;
103881
103909
  let buildInfoDirectory;
103882
- let getCanonicalFileName;
103883
103910
  return diagnostics.map((diagnostic) => {
103884
103911
  const result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath3);
103885
103912
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -103892,7 +103919,7 @@ ${lanes.join("\n")}
103892
103919
  });
103893
103920
  function toPath3(path) {
103894
103921
  buildInfoDirectory != null ? buildInfoDirectory : buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
103895
- return toPath(path, buildInfoDirectory, getCanonicalFileName != null ? getCanonicalFileName : getCanonicalFileName = createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames()));
103922
+ return toPath(path, buildInfoDirectory, newProgram.getCanonicalFileName);
103896
103923
  }
103897
103924
  }
103898
103925
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath3) {
@@ -104063,7 +104090,7 @@ ${lanes.join("\n")}
104063
104090
  sourceFile,
104064
104091
  cancellationToken,
104065
104092
  host,
104066
- !host.disableUseFileVersionAsSignature
104093
+ true
104067
104094
  );
104068
104095
  if (getEmitDeclarations(state.compilerOptions)) {
104069
104096
  addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
@@ -104190,7 +104217,6 @@ ${lanes.join("\n")}
104190
104217
  function getBuildInfo2(state, bundle) {
104191
104218
  var _a2, _b, _c;
104192
104219
  const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
104193
- const getCanonicalFileName = createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
104194
104220
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
104195
104221
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
104196
104222
  const fileNames = [];
@@ -104308,7 +104334,7 @@ ${lanes.join("\n")}
104308
104334
  return relativeToBuildInfo(getNormalizedAbsolutePath(path, currentDirectory));
104309
104335
  }
104310
104336
  function relativeToBuildInfo(path) {
104311
- return ensurePathIsNonModuleName(getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
104337
+ return ensurePathIsNonModuleName(getRelativePathFromDirectory(buildInfoDirectory, path, state.program.getCanonicalFileName));
104312
104338
  }
104313
104339
  function toFileId(path) {
104314
104340
  let fileId = fileNameToFileId.get(path);
@@ -104411,7 +104437,6 @@ ${lanes.join("\n")}
104411
104437
  }
104412
104438
  function computeSignatureWithDiagnostics(program, sourceFile, text, host, data) {
104413
104439
  var _a2, _b;
104414
- let getCanonicalFileName;
104415
104440
  text = getTextHandlingSourceMapForSignature(text, data);
104416
104441
  let sourceFileDirectory;
104417
104442
  if ((_a2 = data == null ? void 0 : data.diagnostics) == null ? void 0 : _a2.length) {
@@ -104431,7 +104456,7 @@ ${lanes.join("\n")}
104431
104456
  return `${ensurePathIsNonModuleName(getRelativePathFromDirectory(
104432
104457
  sourceFileDirectory,
104433
104458
  diagnostic.file.resolvedPath,
104434
- getCanonicalFileName != null ? getCanonicalFileName : getCanonicalFileName = createGetCanonicalFileName(program.useCaseSensitiveFileNames())
104459
+ program.getCanonicalFileName
104435
104460
  ))}(${diagnostic.start},${diagnostic.length})`;
104436
104461
  }
104437
104462
  }
@@ -104446,7 +104471,7 @@ ${lanes.join("\n")}
104446
104471
  oldState = void 0;
104447
104472
  return oldProgram;
104448
104473
  }
104449
- const state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
104474
+ const state = createBuilderProgramState(newProgram, oldState);
104450
104475
  newProgram.getBuildInfo = (bundle) => getBuildInfo2(state, bundle);
104451
104476
  newProgram = void 0;
104452
104477
  oldProgram = void 0;
@@ -104943,9 +104968,9 @@ ${lanes.join("\n")}
104943
104968
  let filesWithInvalidatedResolutions;
104944
104969
  let filesWithInvalidatedNonRelativeUnresolvedImports;
104945
104970
  const nonRelativeExternalModuleResolutions = createMultiMap();
104946
- const resolutionsWithFailedLookups = [];
104947
- const resolutionsWithOnlyAffectingLocations = [];
104948
- const resolvedFileToResolution = createMultiMap();
104971
+ const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
104972
+ const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
104973
+ const resolvedFileToResolution = /* @__PURE__ */ new Map();
104949
104974
  const impliedFormatPackageJsons = /* @__PURE__ */ new Map();
104950
104975
  let hasChangedAutomaticTypeDirectiveNames = false;
104951
104976
  let affectingPathChecksForFile;
@@ -105018,8 +105043,8 @@ ${lanes.join("\n")}
105018
105043
  resolvedModuleNames.clear();
105019
105044
  resolvedTypeReferenceDirectives.clear();
105020
105045
  resolvedFileToResolution.clear();
105021
- resolutionsWithFailedLookups.length = 0;
105022
- resolutionsWithOnlyAffectingLocations.length = 0;
105046
+ resolutionsWithFailedLookups.clear();
105047
+ resolutionsWithOnlyAffectingLocations.clear();
105023
105048
  failedLookupChecks = void 0;
105024
105049
  startsWithPathChecks = void 0;
105025
105050
  isInDirectoryChecks = void 0;
@@ -105336,12 +105361,13 @@ ${lanes.join("\n")}
105336
105361
  return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
105337
105362
  }
105338
105363
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
105364
+ var _a2, _b;
105339
105365
  if (resolution.refCount) {
105340
105366
  resolution.refCount++;
105341
105367
  Debug.assertIsDefined(resolution.files);
105342
105368
  } else {
105343
105369
  resolution.refCount = 1;
105344
- Debug.assert(length(resolution.files) === 0);
105370
+ Debug.assert(!((_a2 = resolution.files) == null ? void 0 : _a2.size));
105345
105371
  if (isExternalModuleNameRelative(name)) {
105346
105372
  watchFailedLookupLocationOfResolution(resolution);
105347
105373
  } else {
@@ -105349,10 +105375,14 @@ ${lanes.join("\n")}
105349
105375
  }
105350
105376
  const resolved = getResolutionWithResolvedFileName(resolution);
105351
105377
  if (resolved && resolved.resolvedFileName) {
105352
- resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
105378
+ const key = resolutionHost.toPath(resolved.resolvedFileName);
105379
+ let resolutions = resolvedFileToResolution.get(key);
105380
+ if (!resolutions)
105381
+ resolvedFileToResolution.set(key, resolutions = /* @__PURE__ */ new Set());
105382
+ resolutions.add(resolution);
105353
105383
  }
105354
105384
  }
105355
- (resolution.files || (resolution.files = [])).push(filePath);
105385
+ ((_b = resolution.files) != null ? _b : resolution.files = /* @__PURE__ */ new Set()).add(filePath);
105356
105386
  }
105357
105387
  function watchFailedLookupLocationOfResolution(resolution) {
105358
105388
  Debug.assert(!!resolution.refCount);
@@ -105360,7 +105390,7 @@ ${lanes.join("\n")}
105360
105390
  if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length))
105361
105391
  return;
105362
105392
  if (failedLookupLocations == null ? void 0 : failedLookupLocations.length)
105363
- resolutionsWithFailedLookups.push(resolution);
105393
+ resolutionsWithFailedLookups.add(resolution);
105364
105394
  let setAtRoot = false;
105365
105395
  if (failedLookupLocations) {
105366
105396
  for (const failedLookupLocation of failedLookupLocations) {
@@ -105392,7 +105422,7 @@ ${lanes.join("\n")}
105392
105422
  if (!(affectingLocations == null ? void 0 : affectingLocations.length))
105393
105423
  return;
105394
105424
  if (addToResolutionsWithOnlyAffectingLocations)
105395
- resolutionsWithOnlyAffectingLocations.push(resolution);
105425
+ resolutionsWithOnlyAffectingLocations.add(resolution);
105396
105426
  for (const affectingLocation of affectingLocations) {
105397
105427
  createFileWatcherOfAffectingLocation(affectingLocation, true);
105398
105428
  }
@@ -105471,17 +105501,20 @@ ${lanes.join("\n")}
105471
105501
  }
105472
105502
  }
105473
105503
  function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
105474
- unorderedRemoveItem(Debug.checkDefined(resolution.files), filePath);
105504
+ Debug.checkDefined(resolution.files).delete(filePath);
105475
105505
  resolution.refCount--;
105476
105506
  if (resolution.refCount) {
105477
105507
  return;
105478
105508
  }
105479
105509
  const resolved = getResolutionWithResolvedFileName(resolution);
105480
105510
  if (resolved && resolved.resolvedFileName) {
105481
- resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
105511
+ const key = resolutionHost.toPath(resolved.resolvedFileName);
105512
+ const resolutions = resolvedFileToResolution.get(key);
105513
+ if ((resolutions == null ? void 0 : resolutions.delete(resolution)) && !resolutions.size)
105514
+ resolvedFileToResolution.delete(key);
105482
105515
  }
105483
105516
  const { failedLookupLocations, affectingLocations } = resolution;
105484
- if (unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
105517
+ if (resolutionsWithFailedLookups.delete(resolution)) {
105485
105518
  let removeAtRoot = false;
105486
105519
  for (const failedLookupLocation of failedLookupLocations) {
105487
105520
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
@@ -105508,7 +105541,7 @@ ${lanes.join("\n")}
105508
105541
  removeDirectoryWatcher(rootPath);
105509
105542
  }
105510
105543
  } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
105511
- unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
105544
+ resolutionsWithOnlyAffectingLocations.delete(resolution);
105512
105545
  }
105513
105546
  if (affectingLocations) {
105514
105547
  for (const affectingLocation of affectingLocations) {
@@ -105556,15 +105589,15 @@ ${lanes.join("\n")}
105556
105589
  if (!resolutions)
105557
105590
  return false;
105558
105591
  let invalidated = false;
105559
- for (const resolution of resolutions) {
105592
+ resolutions.forEach((resolution) => {
105560
105593
  if (resolution.isInvalidated || !canInvalidate(resolution))
105561
- continue;
105594
+ return;
105562
105595
  resolution.isInvalidated = invalidated = true;
105563
105596
  for (const containingFilePath of Debug.checkDefined(resolution.files)) {
105564
105597
  (filesWithInvalidatedResolutions != null ? filesWithInvalidatedResolutions : filesWithInvalidatedResolutions = /* @__PURE__ */ new Set()).add(containingFilePath);
105565
105598
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile);
105566
105599
  }
105567
- }
105600
+ });
105568
105601
  return invalidated;
105569
105602
  }
105570
105603
  function invalidateResolutionOfFile(filePath) {
@@ -105857,8 +105890,7 @@ ${lanes.join("\n")}
105857
105890
  function explainFiles(program, write) {
105858
105891
  var _a2, _b;
105859
105892
  const reasons = program.getFileIncludeReasons();
105860
- const getCanonicalFileName = createGetCanonicalFileName(program.useCaseSensitiveFileNames());
105861
- const relativeFileName = (fileName) => convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName);
105893
+ const relativeFileName = (fileName) => convertToRelativePath(fileName, program.getCurrentDirectory(), program.getCanonicalFileName);
105862
105894
  for (const file of program.getSourceFiles()) {
105863
105895
  write(`${toFileName(file, relativeFileName)}`);
105864
105896
  (_a2 = reasons.get(file.path)) == null ? void 0 : _a2.forEach((reason) => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
@@ -105916,10 +105948,9 @@ ${lanes.join("\n")}
105916
105948
  const configFile = program.getCompilerOptions().configFile;
105917
105949
  if (!((_a2 = configFile == null ? void 0 : configFile.configFileSpecs) == null ? void 0 : _a2.validatedFilesSpec))
105918
105950
  return void 0;
105919
- const getCanonicalFileName = createGetCanonicalFileName(program.useCaseSensitiveFileNames());
105920
- const filePath = getCanonicalFileName(fileName);
105951
+ const filePath = program.getCanonicalFileName(fileName);
105921
105952
  const basePath = getDirectoryPath(getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory()));
105922
- return find(configFile.configFileSpecs.validatedFilesSpec, (fileSpec) => getCanonicalFileName(getNormalizedAbsolutePath(fileSpec, basePath)) === filePath);
105953
+ return find(configFile.configFileSpecs.validatedFilesSpec, (fileSpec) => program.getCanonicalFileName(getNormalizedAbsolutePath(fileSpec, basePath)) === filePath);
105923
105954
  }
105924
105955
  function getMatchedIncludeSpec(program, fileName) {
105925
105956
  var _a2, _b;
@@ -106129,7 +106160,6 @@ ${lanes.join("\n")}
106129
106160
  getEnvironmentVariable: maybeBind(host, host.getEnvironmentVariable) || (() => ""),
106130
106161
  createHash: maybeBind(host, host.createHash),
106131
106162
  readDirectory: maybeBind(host, host.readDirectory),
106132
- disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
106133
106163
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit
106134
106164
  };
106135
106165
  return compilerHost;
@@ -106196,7 +106226,6 @@ ${lanes.join("\n")}
106196
106226
  writeFile: (path, data, writeByteOrderMark) => system.writeFile(path, data, writeByteOrderMark),
106197
106227
  createHash: maybeBind(system, system.createHash),
106198
106228
  createProgram: createProgram2 || createEmitAndSemanticDiagnosticsBuilderProgram,
106199
- disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
106200
106229
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
106201
106230
  now: maybeBind(system, system.now)
106202
106231
  };
@@ -106337,7 +106366,6 @@ ${lanes.join("\n")}
106337
106366
  function createIncrementalCompilerHost(options, system = sys) {
106338
106367
  const host = createCompilerHostWorker(options, void 0, system);
106339
106368
  host.createHash = maybeBind(system, system.createHash);
106340
- host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
106341
106369
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
106342
106370
  setGetSourceFileAsHashVersioned(host);
106343
106371
  changeCompilerHostLikeToUseCache(host, (fileName) => toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName));
@@ -107129,8 +107157,6 @@ ${lanes.join("\n")}
107129
107157
  function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
107130
107158
  const host = hostOrHostWithWatch;
107131
107159
  const hostWithWatch = hostOrHostWithWatch;
107132
- const currentDirectory = host.getCurrentDirectory();
107133
- const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
107134
107160
  const baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
107135
107161
  const compilerHost = createCompilerHostFromProgramHost(host, () => state.projectCompilerOptions);
107136
107162
  setGetSourceFileAsHashVersioned(compilerHost);
@@ -107142,7 +107168,7 @@ ${lanes.join("\n")}
107142
107168
  compilerHost.getModuleResolutionCache = maybeBind(host, host.getModuleResolutionCache);
107143
107169
  let moduleResolutionCache, typeReferenceDirectiveResolutionCache;
107144
107170
  if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) {
107145
- moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName);
107171
+ moduleResolutionCache = createModuleResolutionCache(compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName);
107146
107172
  compilerHost.resolveModuleNameLiterals = (moduleNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
107147
107173
  moduleNames,
107148
107174
  containingFile,
@@ -107156,7 +107182,7 @@ ${lanes.join("\n")}
107156
107182
  compilerHost.getModuleResolutionCache = () => moduleResolutionCache;
107157
107183
  }
107158
107184
  if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) {
107159
- typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
107185
+ typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
107160
107186
  compilerHost.resolveTypeReferenceDirectiveReferences = (typeDirectiveNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
107161
107187
  typeDirectiveNames,
107162
107188
  containingFile,
@@ -107173,8 +107199,6 @@ ${lanes.join("\n")}
107173
107199
  const state = {
107174
107200
  host,
107175
107201
  hostWithWatch,
107176
- currentDirectory,
107177
- getCanonicalFileName,
107178
107202
  parseConfigFileHost: parseConfigHostFromCompilerHostLike(host),
107179
107203
  write: maybeBind(host, host.trace),
107180
107204
  options,
@@ -107218,7 +107242,7 @@ ${lanes.join("\n")}
107218
107242
  return state;
107219
107243
  }
107220
107244
  function toPath2(state, fileName) {
107221
- return toPath(fileName, state.currentDirectory, state.getCanonicalFileName);
107245
+ return toPath(fileName, state.compilerHost.getCurrentDirectory(), state.compilerHost.getCanonicalFileName);
107222
107246
  }
107223
107247
  function toResolvedConfigFilePath(state, fileName) {
107224
107248
  const { resolvedConfigFilePaths } = state;
@@ -107261,7 +107285,7 @@ ${lanes.join("\n")}
107261
107285
  return parsed;
107262
107286
  }
107263
107287
  function resolveProjectName(state, name) {
107264
- return resolveConfigFileProjectName(resolvePath(state.currentDirectory, name));
107288
+ return resolveConfigFileProjectName(resolvePath(state.compilerHost.getCurrentDirectory(), name));
107265
107289
  }
107266
107290
  function createBuildOrder(state, roots) {
107267
107291
  const temporaryMarks = /* @__PURE__ */ new Map();
@@ -107464,7 +107488,7 @@ ${lanes.join("\n")}
107464
107488
  projectPath,
107465
107489
  buildOrder,
107466
107490
  getCompilerOptions: () => config.options,
107467
- getCurrentDirectory: () => state.currentDirectory,
107491
+ getCurrentDirectory: () => state.compilerHost.getCurrentDirectory(),
107468
107492
  updateOutputFileStatmps: () => {
107469
107493
  updateOutputTimestamps(state, config, projectPath);
107470
107494
  updateOutputFileStampsPending = false;
@@ -107489,7 +107513,7 @@ ${lanes.join("\n")}
107489
107513
  projectPath,
107490
107514
  buildOrder,
107491
107515
  getCompilerOptions: () => config.options,
107492
- getCurrentDirectory: () => state.currentDirectory,
107516
+ getCurrentDirectory: () => state.compilerHost.getCurrentDirectory(),
107493
107517
  getBuilderProgram: () => withProgramOrUndefined(identity),
107494
107518
  getProgram: () => withProgramOrUndefined(
107495
107519
  (program2) => program2.getProgramOrUndefined()
@@ -107545,7 +107569,7 @@ ${lanes.join("\n")}
107545
107569
  projectPath,
107546
107570
  buildOrder,
107547
107571
  getCompilerOptions: () => config.options,
107548
- getCurrentDirectory: () => state.currentDirectory,
107572
+ getCurrentDirectory: () => state.compilerHost.getCurrentDirectory(),
107549
107573
  emit: (writeFile2, customTransformers) => {
107550
107574
  if (step !== 4 /* EmitBundle */)
107551
107575
  return invalidatedProjectOfBundle;
@@ -108652,7 +108676,7 @@ ${lanes.join("\n")}
108652
108676
  fileOrDirectory,
108653
108677
  fileOrDirectoryPath: toPath2(state, fileOrDirectory),
108654
108678
  configFileName: resolved,
108655
- currentDirectory: state.currentDirectory,
108679
+ currentDirectory: state.compilerHost.getCurrentDirectory(),
108656
108680
  options: parsed.options,
108657
108681
  program: state.builderPrograms.get(resolvedPath) || ((_a2 = getCachedParsedConfigFile(state, resolvedPath)) == null ? void 0 : _a2.fileNames),
108658
108682
  useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames,
@@ -108757,7 +108781,7 @@ ${lanes.join("\n")}
108757
108781
  };
108758
108782
  }
108759
108783
  function relName(state, path) {
108760
- return convertToRelativePath(path, state.currentDirectory, (f) => state.getCanonicalFileName(f));
108784
+ return convertToRelativePath(path, state.compilerHost.getCurrentDirectory(), state.compilerHost.getCanonicalFileName);
108761
108785
  }
108762
108786
  function reportStatus(state, message, ...args) {
108763
108787
  state.host.reportSolutionBuilderStatus(createCompilerDiagnostic(message, ...args));
@@ -129648,6 +129672,7 @@ ${lanes.join("\n")}
129648
129672
  isTypeOnlyLocation,
129649
129673
  isJsxIdentifierExpected,
129650
129674
  isRightOfOpenTag,
129675
+ isRightOfDotOrQuestionDot,
129651
129676
  importStatementCompletion,
129652
129677
  insideJsDocTagTypeExpression,
129653
129678
  symbolToSortTextMap,
@@ -129713,7 +129738,7 @@ ${lanes.join("\n")}
129713
129738
  getJSCompletionEntries(sourceFile, location.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries);
129714
129739
  }
129715
129740
  let caseBlock;
129716
- if (preferences.includeCompletionsWithInsertText && contextToken && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
129741
+ if (preferences.includeCompletionsWithInsertText && contextToken && !isRightOfOpenTag && !isRightOfDotOrQuestionDot && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
129717
129742
  const cases = getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, compilerOptions, host, program, formatContext);
129718
129743
  if (cases) {
129719
129744
  entries.push(cases.entry);
@@ -131084,6 +131109,7 @@ ${lanes.join("\n")}
131084
131109
  isTypeOnlyLocation,
131085
131110
  isJsxIdentifierExpected,
131086
131111
  isRightOfOpenTag,
131112
+ isRightOfDotOrQuestionDot: isRightOfDot || isRightOfQuestionDot,
131087
131113
  importStatementCompletion,
131088
131114
  hasUnresolvedAutoImports,
131089
131115
  flags
@@ -138178,10 +138204,17 @@ ${lanes.join("\n")}
138178
138204
  const usage = getUsageInfo(oldFile, toMove.all, checker);
138179
138205
  const currentDirectory = getDirectoryPath(oldFile.fileName);
138180
138206
  const extension = extensionFromPath(oldFile.fileName);
138181
- const newModuleName = makeUniqueModuleName(getNewModuleName(usage.oldFileImportsFromNewFile, usage.movedSymbols), extension, currentDirectory, host);
138182
- const newFileNameWithExtension = newModuleName + extension;
138183
- changes.createNewFile(oldFile, combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences));
138184
- addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, hostGetCanonicalFileName(host));
138207
+ const newFilename = combinePaths(
138208
+ currentDirectory,
138209
+ makeUniqueFilename(
138210
+ inferNewFilename(usage.oldFileImportsFromNewFile, usage.movedSymbols),
138211
+ extension,
138212
+ currentDirectory,
138213
+ host
138214
+ )
138215
+ ) + extension;
138216
+ changes.createNewFile(oldFile, newFilename, getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, host, newFilename, preferences));
138217
+ addNewFileToTsconfig(program, changes, oldFile.fileName, newFilename, hostGetCanonicalFileName(host));
138185
138218
  }
138186
138219
  function getStatementsToMove(context) {
138187
138220
  const rangeToMove = getRangeToMove(context);
@@ -138224,7 +138257,7 @@ ${lanes.join("\n")}
138224
138257
  changes.insertNodeInListAfter(cfg, last(filesProp.initializer.elements), factory.createStringLiteral(newFilePath), filesProp.initializer.elements);
138225
138258
  }
138226
138259
  }
138227
- function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) {
138260
+ function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, host, newFilename, preferences) {
138228
138261
  const checker = program.getTypeChecker();
138229
138262
  const prologueDirectives = takeWhile(oldFile.statements, isPrologueDirective);
138230
138263
  if (oldFile.externalModuleIndicator === void 0 && oldFile.commonJsModuleIndicator === void 0 && usage.oldImportsNeededByNewFile.size() === 0) {
@@ -138233,14 +138266,14 @@ ${lanes.join("\n")}
138233
138266
  }
138234
138267
  const useEsModuleSyntax = !!oldFile.externalModuleIndicator;
138235
138268
  const quotePreference = getQuotePreference(oldFile, preferences);
138236
- const importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEsModuleSyntax, quotePreference);
138269
+ const importsFromNewFile = createOldFileImportsFromNewFile(oldFile, usage.oldFileImportsFromNewFile, newFilename, program, host, useEsModuleSyntax, quotePreference);
138237
138270
  if (importsFromNewFile) {
138238
138271
  insertImports(changes, oldFile, importsFromNewFile, true);
138239
138272
  }
138240
138273
  deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
138241
138274
  deleteMovedStatements(oldFile, toMove.ranges, changes);
138242
- updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName);
138243
- const imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference);
138275
+ updateImportsInOtherFiles(changes, program, host, oldFile, usage.movedSymbols, newFilename);
138276
+ const imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, program, host, useEsModuleSyntax, quotePreference);
138244
138277
  const body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax);
138245
138278
  if (imports.length && body.length) {
138246
138279
  return [
@@ -138268,7 +138301,7 @@ ${lanes.join("\n")}
138268
138301
  forEachImportInStatement(statement, (i) => deleteUnusedImports(oldFile, i, changes, (name) => toDelete.has(checker.getSymbolAtLocation(name))));
138269
138302
  }
138270
138303
  }
138271
- function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
138304
+ function updateImportsInOtherFiles(changes, program, host, oldFile, movedSymbols, newFilename) {
138272
138305
  const checker = program.getTypeChecker();
138273
138306
  for (const sourceFile of program.getSourceFiles()) {
138274
138307
  if (sourceFile === oldFile)
@@ -138282,13 +138315,14 @@ ${lanes.join("\n")}
138282
138315
  return !!symbol && movedSymbols.has(symbol);
138283
138316
  };
138284
138317
  deleteUnusedImports(sourceFile, importNode, changes, shouldMove);
138285
- const newModuleSpecifier = combinePaths(getDirectoryPath(moduleSpecifierFromImport(importNode).text), newModuleName);
138318
+ const pathToNewFileWithExtension = resolvePath(getDirectoryPath(oldFile.path), newFilename);
138319
+ const newModuleSpecifier = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.path, pathToNewFileWithExtension, createModuleSpecifierResolutionHost(program, host));
138286
138320
  const newImportDeclaration = filterImport(importNode, factory.createStringLiteral(newModuleSpecifier), shouldMove);
138287
138321
  if (newImportDeclaration)
138288
138322
  changes.insertNodeAfter(sourceFile, statement, newImportDeclaration);
138289
138323
  const ns = getNamespaceLikeImport(importNode);
138290
138324
  if (ns)
138291
- updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, ns, importNode);
138325
+ updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleSpecifier, ns, importNode);
138292
138326
  });
138293
138327
  }
138294
138328
  }
@@ -138305,8 +138339,8 @@ ${lanes.join("\n")}
138305
138339
  return Debug.assertNever(node, `Unexpected node kind ${node.kind}`);
138306
138340
  }
138307
138341
  }
138308
- function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) {
138309
- const preferredNewNamespaceName = ts_codefix_exports.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ESNext */);
138342
+ function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleSpecifier, oldImportId, oldImportNode) {
138343
+ const preferredNewNamespaceName = ts_codefix_exports.moduleSpecifierToValidIdentifier(newModuleSpecifier, 99 /* ESNext */);
138310
138344
  let needUniqueName = false;
138311
138345
  const toChange = [];
138312
138346
  ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, (ref) => {
@@ -138322,7 +138356,7 @@ ${lanes.join("\n")}
138322
138356
  for (const ref of toChange) {
138323
138357
  changes.replaceNode(sourceFile, ref, factory.createIdentifier(newNamespaceName));
138324
138358
  }
138325
- changes.insertNodeAfter(sourceFile, oldImportNode, updateNamespaceLikeImportNode(oldImportNode, newModuleName, newModuleSpecifier));
138359
+ changes.insertNodeAfter(sourceFile, oldImportNode, updateNamespaceLikeImportNode(oldImportNode, preferredNewNamespaceName, newModuleSpecifier));
138326
138360
  }
138327
138361
  }
138328
138362
  function updateNamespaceLikeImportNode(node, newNamespaceName, newModuleSpecifier) {
@@ -138363,7 +138397,7 @@ ${lanes.join("\n")}
138363
138397
  }
138364
138398
  }
138365
138399
  }
138366
- function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports, quotePreference) {
138400
+ function createOldFileImportsFromNewFile(sourceFile, newFileNeedExport, newFileNameWithExtension, program, host, useEs6Imports, quotePreference) {
138367
138401
  let defaultImport;
138368
138402
  const imports = [];
138369
138403
  newFileNeedExport.forEach((symbol) => {
@@ -138373,17 +138407,18 @@ ${lanes.join("\n")}
138373
138407
  imports.push(symbol.name);
138374
138408
  }
138375
138409
  });
138376
- return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports, quotePreference);
138410
+ return makeImportOrRequire(sourceFile, defaultImport, imports, newFileNameWithExtension, program, host, useEs6Imports, quotePreference);
138377
138411
  }
138378
- function makeImportOrRequire(defaultImport, imports, path, useEs6Imports, quotePreference) {
138379
- path = ensurePathIsNonModuleName(path);
138412
+ function makeImportOrRequire(sourceFile, defaultImport, imports, newFileNameWithExtension, program, host, useEs6Imports, quotePreference) {
138413
+ const pathToNewFile = resolvePath(getDirectoryPath(sourceFile.path), newFileNameWithExtension);
138414
+ const pathToNewFileWithCorrectExtension = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.path, pathToNewFile, createModuleSpecifierResolutionHost(program, host));
138380
138415
  if (useEs6Imports) {
138381
138416
  const specifiers = imports.map((i) => factory.createImportSpecifier(false, void 0, factory.createIdentifier(i)));
138382
- return makeImportIfNecessary(defaultImport, specifiers, path, quotePreference);
138417
+ return makeImportIfNecessary(defaultImport, specifiers, pathToNewFileWithCorrectExtension, quotePreference);
138383
138418
  } else {
138384
138419
  Debug.assert(!defaultImport, "No default import should exist");
138385
138420
  const bindingElements = imports.map((i) => factory.createBindingElement(void 0, void 0, i));
138386
- return bindingElements.length ? makeVariableStatement(factory.createObjectBindingPattern(bindingElements), void 0, createRequireCall(factory.createStringLiteral(path))) : void 0;
138421
+ return bindingElements.length ? makeVariableStatement(factory.createObjectBindingPattern(bindingElements), void 0, createRequireCall(factory.createStringLiteral(pathToNewFileWithCorrectExtension))) : void 0;
138387
138422
  }
138388
138423
  }
138389
138424
  function makeVariableStatement(name, type, initializer, flags = 2 /* Const */) {
@@ -138480,7 +138515,7 @@ ${lanes.join("\n")}
138480
138515
  break;
138481
138516
  }
138482
138517
  }
138483
- function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference) {
138518
+ function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, program, host, useEsModuleSyntax, quotePreference) {
138484
138519
  const copiedOldImports = [];
138485
138520
  for (const oldStatement of oldFile.statements) {
138486
138521
  forEachImportInStatement(oldStatement, (i) => {
@@ -138511,19 +138546,19 @@ ${lanes.join("\n")}
138511
138546
  }
138512
138547
  }
138513
138548
  });
138514
- append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, removeFileExtension(getBaseFileName(oldFile.fileName)), useEsModuleSyntax, quotePreference));
138549
+ append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, getBaseFileName(oldFile.fileName), program, host, useEsModuleSyntax, quotePreference));
138515
138550
  return copiedOldImports;
138516
138551
  }
138517
- function makeUniqueModuleName(moduleName, extension, inDirectory, host) {
138518
- let newModuleName = moduleName;
138552
+ function makeUniqueFilename(proposedFilename, extension, inDirectory, host) {
138553
+ let newFilename = proposedFilename;
138519
138554
  for (let i = 1; ; i++) {
138520
- const name = combinePaths(inDirectory, newModuleName + extension);
138555
+ const name = combinePaths(inDirectory, newFilename + extension);
138521
138556
  if (!host.fileExists(name))
138522
- return newModuleName;
138523
- newModuleName = `${moduleName}.${i}`;
138557
+ return newFilename;
138558
+ newFilename = `${proposedFilename}.${i}`;
138524
138559
  }
138525
138560
  }
138526
- function getNewModuleName(importsFromNewFile, movedSymbols) {
138561
+ function inferNewFilename(importsFromNewFile, movedSymbols) {
138527
138562
  return importsFromNewFile.forEachEntry(symbolNameNoDefault) || movedSymbols.forEachEntry(symbolNameNoDefault) || "newFile";
138528
138563
  }
138529
138564
  function getUsageInfo(oldFile, toMove, checker) {
@@ -138797,6 +138832,7 @@ ${lanes.join("\n")}
138797
138832
  var init_moveToNewFile = __esm({
138798
138833
  "src/services/refactors/moveToNewFile.ts"() {
138799
138834
  "use strict";
138835
+ init_moduleSpecifiers();
138800
138836
  init_ts4();
138801
138837
  init_ts_refactor();
138802
138838
  refactorName4 = "Move to a new file";