typescript 5.3.0-dev.20231010 → 5.3.0-dev.20231011

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
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.3";
38
- version = `${versionMajorMinor}.0-dev.20231010`;
38
+ version = `${versionMajorMinor}.0-dev.20231011`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -39253,7 +39253,7 @@ ${lanes.join("\n")}
39253
39253
  Debug.assert(extensionIsTS(resolved.extension));
39254
39254
  return { fileName: resolved.path, packageId: resolved.packageId };
39255
39255
  }
39256
- function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, legacyResult) {
39256
+ function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, cache, legacyResult) {
39257
39257
  if (!state.resultFromCache && !state.compilerOptions.preserveSymlinks && resolved && isExternalLibraryImport && !resolved.originalPath && !isExternalModuleNameRelative(moduleName)) {
39258
39258
  const { resolvedFileName, originalPath } = getOriginalAndResolvedFileName(resolved.path, state.host, state.traceEnabled);
39259
39259
  if (originalPath)
@@ -39266,15 +39266,25 @@ ${lanes.join("\n")}
39266
39266
  affectingLocations,
39267
39267
  diagnostics,
39268
39268
  state.resultFromCache,
39269
+ cache,
39269
39270
  legacyResult
39270
39271
  );
39271
39272
  }
39272
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, legacyResult) {
39273
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, legacyResult) {
39273
39274
  if (resultFromCache) {
39274
- resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
39275
- resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
39276
- resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
39277
- return resultFromCache;
39275
+ if (!(cache == null ? void 0 : cache.isReadonly)) {
39276
+ resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
39277
+ resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
39278
+ resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
39279
+ return resultFromCache;
39280
+ } else {
39281
+ return {
39282
+ ...resultFromCache,
39283
+ failedLookupLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.failedLookupLocations, failedLookupLocations),
39284
+ affectingLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.affectingLocations, affectingLocations),
39285
+ resolutionDiagnostics: initializeResolutionFieldForReadonlyCache(resultFromCache.resolutionDiagnostics, diagnostics)
39286
+ };
39287
+ }
39278
39288
  }
39279
39289
  return {
39280
39290
  resolvedModule: resolved && {
@@ -39302,6 +39312,13 @@ ${lanes.join("\n")}
39302
39312
  to.push(...value);
39303
39313
  return to;
39304
39314
  }
39315
+ function initializeResolutionFieldForReadonlyCache(fromCache, value) {
39316
+ if (!(fromCache == null ? void 0 : fromCache.length))
39317
+ return initializeResolutionField(value);
39318
+ if (!value.length)
39319
+ return fromCache.slice();
39320
+ return [...fromCache, ...value];
39321
+ }
39305
39322
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
39306
39323
  if (!hasProperty(jsonContent, fieldName)) {
39307
39324
  if (state.traceEnabled) {
@@ -39527,15 +39544,15 @@ ${lanes.join("\n")}
39527
39544
  affectingLocations: initializeResolutionField(affectingLocations),
39528
39545
  resolutionDiagnostics: initializeResolutionField(diagnostics)
39529
39546
  };
39530
- if (containingDirectory) {
39531
- cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(
39547
+ if (containingDirectory && cache && !cache.isReadonly) {
39548
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(
39532
39549
  typeReferenceDirectiveName,
39533
39550
  /*mode*/
39534
39551
  resolutionMode,
39535
39552
  result
39536
39553
  );
39537
39554
  if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
39538
- cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result);
39555
+ cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result);
39539
39556
  }
39540
39557
  }
39541
39558
  if (traceEnabled)
@@ -39742,7 +39759,8 @@ ${lanes.join("\n")}
39742
39759
  getMapOfCacheRedirects,
39743
39760
  getOrCreateMapOfCacheRedirects,
39744
39761
  update,
39745
- clear: clear2
39762
+ clear: clear2,
39763
+ getOwnMap: () => ownMap
39746
39764
  };
39747
39765
  function getMapOfCacheRedirects(redirectedReference) {
39748
39766
  return redirectedReference ? getOrCreateMap(
@@ -39849,7 +39867,8 @@ ${lanes.join("\n")}
39849
39867
  getFromDirectoryCache,
39850
39868
  getOrCreateCacheForDirectory,
39851
39869
  clear: clear2,
39852
- update
39870
+ update,
39871
+ directoryToModuleNameMap
39853
39872
  };
39854
39873
  function clear2() {
39855
39874
  directoryToModuleNameMap.clear();
@@ -40123,9 +40142,11 @@ ${lanes.join("\n")}
40123
40142
  if (result && result.resolvedModule)
40124
40143
  (_b = perfLogger) == null ? void 0 : _b.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`);
40125
40144
  (_c = perfLogger) == null ? void 0 : _c.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null");
40126
- cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
40127
- if (!isExternalModuleNameRelative(moduleName)) {
40128
- cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
40145
+ if (cache && !cache.isReadonly) {
40146
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
40147
+ if (!isExternalModuleNameRelative(moduleName)) {
40148
+ cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
40149
+ }
40129
40150
  }
40130
40151
  }
40131
40152
  if (traceEnabled) {
@@ -40427,6 +40448,7 @@ ${lanes.join("\n")}
40427
40448
  affectingLocations,
40428
40449
  diagnostics,
40429
40450
  state,
40451
+ cache,
40430
40452
  legacyResult
40431
40453
  );
40432
40454
  function tryResolve(extensions2, state2) {
@@ -40827,7 +40849,7 @@ ${lanes.join("\n")}
40827
40849
  return packageJsonInfo.contents.versionPaths || void 0;
40828
40850
  }
40829
40851
  function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
40830
- var _a, _b, _c, _d, _e, _f, _g, _h;
40852
+ var _a, _b, _c, _d, _e, _f;
40831
40853
  const { host, traceEnabled } = state;
40832
40854
  const packageJsonPath = combinePaths(packageDirectory, "package.json");
40833
40855
  if (onlyRecordFailures) {
@@ -40855,15 +40877,17 @@ ${lanes.join("\n")}
40855
40877
  trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath);
40856
40878
  }
40857
40879
  const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } };
40858
- (_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result);
40859
- (_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath);
40880
+ if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly)
40881
+ state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, result);
40882
+ (_e = state.affectingLocations) == null ? void 0 : _e.push(packageJsonPath);
40860
40883
  return result;
40861
40884
  } else {
40862
40885
  if (directoryExists && traceEnabled) {
40863
40886
  trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
40864
40887
  }
40865
- (_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists);
40866
- (_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath);
40888
+ if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly)
40889
+ state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, directoryExists);
40890
+ (_f = state.failedLookupLocations) == null ? void 0 : _f.push(packageJsonPath);
40867
40891
  }
40868
40892
  }
40869
40893
  function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
@@ -41652,7 +41676,8 @@ ${lanes.join("\n")}
41652
41676
  failedLookupLocations,
41653
41677
  affectingLocations,
41654
41678
  diagnostics,
41655
- state
41679
+ state,
41680
+ cache
41656
41681
  );
41657
41682
  function tryResolve(extensions) {
41658
41683
  const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
@@ -41771,7 +41796,9 @@ ${lanes.join("\n")}
41771
41796
  failedLookupLocations,
41772
41797
  affectingLocations,
41773
41798
  diagnostics,
41774
- state.resultFromCache
41799
+ state.resultFromCache,
41800
+ /*cache*/
41801
+ void 0
41775
41802
  );
41776
41803
  }
41777
41804
  function toSearchResult(value) {
@@ -75830,8 +75857,20 @@ ${lanes.join("\n")}
75830
75857
  let hasReturnWithNoExpression = functionHasImplicitReturn(func);
75831
75858
  let hasReturnOfTypeNever = false;
75832
75859
  forEachReturnStatement(func.body, (returnStatement) => {
75833
- const expr = returnStatement.expression;
75860
+ let expr = returnStatement.expression;
75834
75861
  if (expr) {
75862
+ expr = skipParentheses(
75863
+ expr,
75864
+ /*excludeJSDocTypeAssertions*/
75865
+ true
75866
+ );
75867
+ if (functionFlags & 2 /* Async */ && expr.kind === 223 /* AwaitExpression */) {
75868
+ expr = skipParentheses(
75869
+ expr.expression,
75870
+ /*excludeJSDocTypeAssertions*/
75871
+ true
75872
+ );
75873
+ }
75835
75874
  if (expr.kind === 213 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) {
75836
75875
  hasReturnOfTypeNever = true;
75837
75876
  return;
@@ -124126,6 +124165,10 @@ ${lanes.join("\n")}
124126
124165
  function getRootPathSplitLength(rootPath) {
124127
124166
  return rootPath.split(directorySeparator).length - (hasTrailingDirectorySeparator(rootPath) ? 1 : 0);
124128
124167
  }
124168
+ function getModuleResolutionHost(resolutionHost) {
124169
+ var _a;
124170
+ return ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost;
124171
+ }
124129
124172
  function createModuleResolutionLoaderUsingGlobalCache(containingFile, redirectedReference, options, resolutionHost, moduleResolutionCache) {
124130
124173
  return {
124131
124174
  nameAndMode: moduleResolutionNameAndModeGetter,
@@ -124141,8 +124184,7 @@ ${lanes.join("\n")}
124141
124184
  };
124142
124185
  }
124143
124186
  function resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, compilerOptions, redirectedReference, mode) {
124144
- var _a;
124145
- const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost;
124187
+ const host = getModuleResolutionHost(resolutionHost);
124146
124188
  const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
124147
124189
  if (!resolutionHost.getGlobalCache) {
124148
124190
  return primaryResult;
@@ -124313,6 +124355,10 @@ ${lanes.join("\n")}
124313
124355
  };
124314
124356
  }
124315
124357
  function startCachingPerDirectoryResolution() {
124358
+ moduleResolutionCache.isReadonly = void 0;
124359
+ typeReferenceDirectiveResolutionCache.isReadonly = void 0;
124360
+ libraryResolutionCache.isReadonly = void 0;
124361
+ moduleResolutionCache.getPackageJsonInfoCache().isReadonly = void 0;
124316
124362
  moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
124317
124363
  typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
124318
124364
  libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
@@ -124370,6 +124416,10 @@ ${lanes.join("\n")}
124370
124416
  directoryWatchesOfFailedLookups.forEach(closeDirectoryWatchesOfFailedLookup);
124371
124417
  fileWatchesOfAffectingLocations.forEach(closeFileWatcherOfAffectingLocation);
124372
124418
  hasChangedAutomaticTypeDirectiveNames = false;
124419
+ moduleResolutionCache.isReadonly = true;
124420
+ typeReferenceDirectiveResolutionCache.isReadonly = true;
124421
+ libraryResolutionCache.isReadonly = true;
124422
+ moduleResolutionCache.getPackageJsonInfoCache().isReadonly = true;
124373
124423
  }
124374
124424
  function closeDirectoryWatchesOfFailedLookup(watcher, path) {
124375
124425
  if (watcher.refCount === 0) {
@@ -124398,7 +124448,6 @@ ${lanes.join("\n")}
124398
124448
  shouldRetryResolution,
124399
124449
  logChanges
124400
124450
  }) {
124401
- var _a;
124402
124451
  const path = resolutionHost.toPath(containingFile);
124403
124452
  const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path);
124404
124453
  const resolvedModules = [];
@@ -124430,7 +124479,7 @@ ${lanes.join("\n")}
124430
124479
  logChanges = false;
124431
124480
  }
124432
124481
  } else {
124433
- const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost;
124482
+ const host = getModuleResolutionHost(resolutionHost);
124434
124483
  if (isTraceEnabled(options, host) && !seenNamesInFile.has(name, mode)) {
124435
124484
  const resolved = getResolutionWithResolvedFileName(resolution);
124436
124485
  trace(
@@ -124482,7 +124531,6 @@ ${lanes.join("\n")}
124482
124531
  }
124483
124532
  }
124484
124533
  function resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
124485
- var _a;
124486
124534
  return resolveNamesWithLocalCache({
124487
124535
  entries: typeDirectiveReferences,
124488
124536
  containingFile,
@@ -124495,7 +124543,7 @@ ${lanes.join("\n")}
124495
124543
  containingFile,
124496
124544
  redirectedReference,
124497
124545
  options,
124498
- ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost,
124546
+ getModuleResolutionHost(resolutionHost),
124499
124547
  typeReferenceDirectiveResolutionCache
124500
124548
  ),
124501
124549
  getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
@@ -124527,8 +124575,7 @@ ${lanes.join("\n")}
124527
124575
  });
124528
124576
  }
124529
124577
  function resolveLibrary2(libraryName, resolveFrom, options, libFileName) {
124530
- var _a;
124531
- const host = ((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost;
124578
+ const host = getModuleResolutionHost(resolutionHost);
124532
124579
  let resolution = resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName);
124533
124580
  if (!resolution || resolution.isInvalidated) {
124534
124581
  const existingResolution = resolution;
@@ -124562,6 +124609,7 @@ ${lanes.join("\n")}
124562
124609
  return resolution;
124563
124610
  }
124564
124611
  function resolveSingleModuleNameWithoutWatching(moduleName, containingFile) {
124612
+ var _a, _b;
124565
124613
  const path = resolutionHost.toPath(containingFile);
124566
124614
  const resolutionsInFile = resolvedModuleNames.get(path);
124567
124615
  const resolution = resolutionsInFile == null ? void 0 : resolutionsInFile.get(
@@ -124571,7 +124619,17 @@ ${lanes.join("\n")}
124571
124619
  );
124572
124620
  if (resolution && !resolution.isInvalidated)
124573
124621
  return resolution;
124574
- return resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, resolutionHost.getCompilationSettings());
124622
+ const data = (_a = resolutionHost.beforeResolveSingleModuleNameWithoutWatching) == null ? void 0 : _a.call(resolutionHost, moduleResolutionCache);
124623
+ const host = getModuleResolutionHost(resolutionHost);
124624
+ const result = resolveModuleName(
124625
+ moduleName,
124626
+ containingFile,
124627
+ resolutionHost.getCompilationSettings(),
124628
+ host,
124629
+ moduleResolutionCache
124630
+ );
124631
+ (_b = resolutionHost.afterResolveSingleModuleNameWithoutWatching) == null ? void 0 : _b.call(resolutionHost, moduleResolutionCache, moduleName, containingFile, result, data);
124632
+ return result;
124575
124633
  }
124576
124634
  function isNodeModulesAtTypesDirectory(dirPath) {
124577
124635
  return endsWith(dirPath, "/node_modules/@types");
@@ -172634,7 +172692,7 @@ ${options.prefix}` : "\n" : options.prefix
172634
172692
  return fileName[0] === "^" || (fileName.includes("walkThroughSnippet:/") || fileName.includes("untitled:/")) && getBaseFileName(fileName)[0] === "^" || fileName.includes(":^") && !fileName.includes(directorySeparator);
172635
172693
  }
172636
172694
  function ensurePrimaryProjectKind(project) {
172637
- if (!project || project.projectKind === 3 /* AutoImportProvider */ || project.projectKind === 4 /* Auxiliary */) {
172695
+ if (!project || isBackgroundProject(project)) {
172638
172696
  return Errors.ThrowNoProject();
172639
172697
  }
172640
172698
  return project;
@@ -173096,7 +173154,7 @@ ${options.prefix}` : "\n" : options.prefix
173096
173154
  isContainedByBackgroundProject() {
173097
173155
  return some(
173098
173156
  this.containingProjects,
173099
- (p) => p.projectKind === 3 /* AutoImportProvider */ || p.projectKind === 4 /* Auxiliary */
173157
+ isBackgroundProject
173100
173158
  );
173101
173159
  }
173102
173160
  /**
@@ -173332,6 +173390,9 @@ ${options.prefix}` : "\n" : options.prefix
173332
173390
  function isExternalProject(project) {
173333
173391
  return project.projectKind === 2 /* External */;
173334
173392
  }
173393
+ function isBackgroundProject(project) {
173394
+ return project.projectKind === 3 /* AutoImportProvider */ || project.projectKind === 4 /* Auxiliary */;
173395
+ }
173335
173396
  var ProjectKind, Project3, InferredProject2, AuxiliaryProject, _AutoImportProviderProject, AutoImportProviderProject, ConfiguredProject2, ExternalProject2;
173336
173397
  var init_project = __esm({
173337
173398
  "src/server/project.ts"() {
@@ -173448,9 +173509,10 @@ ${options.prefix}` : "\n" : options.prefix
173448
173509
  this.disableLanguageService(lastFileExceededProgramSize);
173449
173510
  }
173450
173511
  this.markAsDirty();
173451
- if (projectKind !== 3 /* AutoImportProvider */) {
173512
+ if (!isBackgroundProject(this)) {
173452
173513
  this.projectService.pendingEnsureProjectForOpenFiles = true;
173453
173514
  }
173515
+ this.projectService.onProjectCreation(this);
173454
173516
  }
173455
173517
  /** @internal */
173456
173518
  getResolvedProjectReferenceToRedirect(_fileName) {
@@ -173620,6 +173682,7 @@ ${options.prefix}` : "\n" : options.prefix
173620
173682
  resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
173621
173683
  return this.resolutionCache.resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames);
173622
173684
  }
173685
+ /** @internal */
173623
173686
  getModuleResolutionCache() {
173624
173687
  return this.resolutionCache.getModuleResolutionCache();
173625
173688
  }
@@ -174898,32 +174961,15 @@ ${options.prefix}` : "\n" : options.prefix
174898
174961
  return this.projectService.getIncompleteCompletionsCache();
174899
174962
  }
174900
174963
  /** @internal */
174901
- getNoDtsResolutionProject(rootFileNames) {
174964
+ getNoDtsResolutionProject(rootFile) {
174902
174965
  Debug.assert(this.projectService.serverMode === 0 /* Semantic */);
174903
174966
  if (!this.noDtsResolutionProject) {
174904
174967
  this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject(), this.currentDirectory);
174905
174968
  }
174906
- enumerateInsertsAndDeletes(
174907
- rootFileNames.map(toNormalizedPath),
174908
- this.noDtsResolutionProject.getRootFiles(),
174909
- getStringComparer(!this.useCaseSensitiveFileNames()),
174910
- (pathToAdd) => {
174911
- const info = this.projectService.getOrCreateScriptInfoNotOpenedByClient(
174912
- pathToAdd,
174913
- this.currentDirectory,
174914
- this.noDtsResolutionProject.directoryStructureHost
174915
- );
174916
- if (info) {
174917
- this.noDtsResolutionProject.addRoot(info, pathToAdd);
174918
- }
174919
- },
174920
- (pathToRemove) => {
174921
- const info = this.noDtsResolutionProject.getScriptInfo(pathToRemove);
174922
- if (info) {
174923
- this.noDtsResolutionProject.removeRoot(info);
174924
- }
174925
- }
174926
- );
174969
+ if (this.noDtsResolutionProject.rootFile !== rootFile) {
174970
+ this.projectService.setFileNamesOfAutpImportProviderOrAuxillaryProject(this.noDtsResolutionProject, [rootFile]);
174971
+ this.noDtsResolutionProject.rootFile = rootFile;
174972
+ }
174927
174973
  return this.noDtsResolutionProject;
174928
174974
  }
174929
174975
  /** @internal */
@@ -175230,7 +175276,7 @@ ${options.prefix}` : "\n" : options.prefix
175230
175276
  this.getCompilationSettings()
175231
175277
  );
175232
175278
  }
175233
- this.projectService.setFileNamesOfAutoImportProviderProject(this, rootFileNames);
175279
+ this.projectService.setFileNamesOfAutpImportProviderOrAuxillaryProject(this, rootFileNames);
175234
175280
  this.rootFileNames = rootFileNames;
175235
175281
  const oldProgram = this.getCurrentProgram();
175236
175282
  const hasSameSetOfFiles = super.updateGraph();
@@ -176053,6 +176099,8 @@ ${options.prefix}` : "\n" : options.prefix
176053
176099
  this.verifyDocumentRegistry = noop;
176054
176100
  /** @internal */
176055
176101
  this.verifyProgram = noop;
176102
+ /** @internal */
176103
+ this.onProjectCreation = noop;
176056
176104
  var _a;
176057
176105
  this.host = opts.host;
176058
176106
  this.logger = opts.logger;
@@ -176220,20 +176268,20 @@ ${options.prefix}` : "\n" : options.prefix
176220
176268
  }
176221
176269
  delayUpdateProjectGraph(project) {
176222
176270
  project.markAsDirty();
176223
- if (project.projectKind !== 3 /* AutoImportProvider */ && project.projectKind !== 4 /* Auxiliary */) {
176224
- const projectName = project.getProjectName();
176225
- this.pendingProjectUpdates.set(projectName, project);
176226
- this.throttledOperations.schedule(
176227
- projectName,
176228
- /*delay*/
176229
- 250,
176230
- () => {
176231
- if (this.pendingProjectUpdates.delete(projectName)) {
176232
- updateProjectIfDirty(project);
176233
- }
176271
+ if (isBackgroundProject(project))
176272
+ return;
176273
+ const projectName = project.getProjectName();
176274
+ this.pendingProjectUpdates.set(projectName, project);
176275
+ this.throttledOperations.schedule(
176276
+ projectName,
176277
+ /*delay*/
176278
+ 250,
176279
+ () => {
176280
+ if (this.pendingProjectUpdates.delete(projectName)) {
176281
+ updateProjectIfDirty(project);
176234
176282
  }
176235
- );
176236
- }
176283
+ }
176284
+ );
176237
176285
  }
176238
176286
  /** @internal */
176239
176287
  hasPendingProjectUpdate(project) {
@@ -177090,6 +177138,7 @@ ${options.prefix}` : "\n" : options.prefix
177090
177138
  addFilesToNonInferredProject(project, files, propertyReader, typeAcquisition) {
177091
177139
  this.updateNonInferredProjectFiles(project, files, propertyReader);
177092
177140
  project.setTypeAcquisition(typeAcquisition);
177141
+ project.markAsDirty();
177093
177142
  }
177094
177143
  /** @internal */
177095
177144
  createConfiguredProject(configFileName) {
@@ -177375,7 +177424,6 @@ ${options.prefix}` : "\n" : options.prefix
177375
177424
  }
177376
177425
  });
177377
177426
  }
177378
- project.markAsDirty();
177379
177427
  }
177380
177428
  updateRootAndOptionsOfNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, watchOptions) {
177381
177429
  project.setCompilerOptions(newOptions);
@@ -177394,6 +177442,7 @@ ${options.prefix}` : "\n" : options.prefix
177394
177442
  const fileNames = this.reloadFileNamesOfParsedConfig(project.getConfigFilePath(), this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath).config);
177395
177443
  project.updateErrorOnNoInputFiles(fileNames);
177396
177444
  this.updateNonInferredProjectFiles(project, fileNames.concat(project.getExternalFiles(1 /* RootNamesAndUpdate */)), fileNamePropertyReader);
177445
+ project.markAsDirty();
177397
177446
  return project.updateGraph();
177398
177447
  }
177399
177448
  /** @internal */
@@ -177413,7 +177462,7 @@ ${options.prefix}` : "\n" : options.prefix
177413
177462
  return fileNames;
177414
177463
  }
177415
177464
  /** @internal */
177416
- setFileNamesOfAutoImportProviderProject(project, fileNames) {
177465
+ setFileNamesOfAutpImportProviderOrAuxillaryProject(project, fileNames) {
177417
177466
  this.updateNonInferredProjectFiles(project, fileNames, fileNamePropertyReader);
177418
177467
  }
177419
177468
  /**
@@ -180878,7 +180927,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
180878
180927
  if (needsJsResolution) {
180879
180928
  const definitionSet = createSet((d) => d.textSpan.start, documentSpansEqual);
180880
180929
  definitions == null ? void 0 : definitions.forEach((d) => definitionSet.add(d));
180881
- const noDtsProject = project.getNoDtsResolutionProject([file]);
180930
+ const noDtsProject = project.getNoDtsResolutionProject(file);
180882
180931
  const ls = noDtsProject.getLanguageService();
180883
180932
  const jsDefinitions = (_a = ls.getDefinitionAtPosition(
180884
180933
  file,
@@ -180905,8 +180954,18 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
180905
180954
  const ambientCandidates = definitions.filter((d) => toNormalizedPath(d.fileName) !== file && d.isAmbient);
180906
180955
  for (const candidate of some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain()) {
180907
180956
  const fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject);
180908
- if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) {
180957
+ if (!fileNameToSearch)
180909
180958
  continue;
180959
+ const info = this.projectService.getOrCreateScriptInfoNotOpenedByClient(
180960
+ fileNameToSearch,
180961
+ noDtsProject.currentDirectory,
180962
+ noDtsProject.directoryStructureHost
180963
+ );
180964
+ if (!info)
180965
+ continue;
180966
+ if (!noDtsProject.containsScriptInfo(info)) {
180967
+ noDtsProject.addRoot(info);
180968
+ noDtsProject.updateGraph();
180910
180969
  }
180911
180970
  const noDtsProgram = ls.getProgram();
180912
180971
  const fileToSearch = Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch));
@@ -181009,16 +181068,6 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
181009
181068
  }
181010
181069
  });
181011
181070
  }
181012
- function ensureRoot(project2, fileName) {
181013
- const info = project2.getScriptInfo(fileName);
181014
- if (!info)
181015
- return false;
181016
- if (!project2.containsScriptInfo(info)) {
181017
- project2.addRoot(info);
181018
- project2.updateGraph();
181019
- }
181020
- return true;
181021
- }
181022
181071
  }
181023
181072
  getEmitOutput(args) {
181024
181073
  const { file, project } = this.getFileAndProject(args);
@@ -183278,6 +183327,7 @@ ${e.message}`;
183278
183327
  hasArgument: () => hasArgument,
183279
183328
  hasNoTypeScriptSource: () => hasNoTypeScriptSource,
183280
183329
  indent: () => indent2,
183330
+ isBackgroundProject: () => isBackgroundProject,
183281
183331
  isConfigFile: () => isConfigFile,
183282
183332
  isConfiguredProject: () => isConfiguredProject,
183283
183333
  isDynamicFileName: () => isDynamicFileName,
@@ -185697,6 +185747,7 @@ ${e.message}`;
185697
185747
  hasArgument: () => hasArgument,
185698
185748
  hasNoTypeScriptSource: () => hasNoTypeScriptSource,
185699
185749
  indent: () => indent2,
185750
+ isBackgroundProject: () => isBackgroundProject,
185700
185751
  isConfigFile: () => isConfigFile,
185701
185752
  isConfiguredProject: () => isConfiguredProject,
185702
185753
  isDynamicFileName: () => isDynamicFileName,
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.3";
57
- var version = `${versionMajorMinor}.0-dev.20231010`;
57
+ var version = `${versionMajorMinor}.0-dev.20231011`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -27367,7 +27367,7 @@ function formatExtensions(extensions) {
27367
27367
  result.push("JSON");
27368
27368
  return result.join(", ");
27369
27369
  }
27370
- function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, legacyResult) {
27370
+ function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, cache, legacyResult) {
27371
27371
  if (!state.resultFromCache && !state.compilerOptions.preserveSymlinks && resolved && isExternalLibraryImport && !resolved.originalPath && !isExternalModuleNameRelative(moduleName)) {
27372
27372
  const { resolvedFileName, originalPath } = getOriginalAndResolvedFileName(resolved.path, state.host, state.traceEnabled);
27373
27373
  if (originalPath)
@@ -27380,15 +27380,25 @@ function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName
27380
27380
  affectingLocations,
27381
27381
  diagnostics,
27382
27382
  state.resultFromCache,
27383
+ cache,
27383
27384
  legacyResult
27384
27385
  );
27385
27386
  }
27386
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, legacyResult) {
27387
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, legacyResult) {
27387
27388
  if (resultFromCache) {
27388
- resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
27389
- resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
27390
- resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
27391
- return resultFromCache;
27389
+ if (!(cache == null ? void 0 : cache.isReadonly)) {
27390
+ resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
27391
+ resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
27392
+ resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
27393
+ return resultFromCache;
27394
+ } else {
27395
+ return {
27396
+ ...resultFromCache,
27397
+ failedLookupLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.failedLookupLocations, failedLookupLocations),
27398
+ affectingLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.affectingLocations, affectingLocations),
27399
+ resolutionDiagnostics: initializeResolutionFieldForReadonlyCache(resultFromCache.resolutionDiagnostics, diagnostics)
27400
+ };
27401
+ }
27392
27402
  }
27393
27403
  return {
27394
27404
  resolvedModule: resolved && {
@@ -27416,6 +27426,13 @@ function updateResolutionField(to, value) {
27416
27426
  to.push(...value);
27417
27427
  return to;
27418
27428
  }
27429
+ function initializeResolutionFieldForReadonlyCache(fromCache, value) {
27430
+ if (!(fromCache == null ? void 0 : fromCache.length))
27431
+ return initializeResolutionField(value);
27432
+ if (!value.length)
27433
+ return fromCache.slice();
27434
+ return [...fromCache, ...value];
27435
+ }
27419
27436
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
27420
27437
  if (!hasProperty(jsonContent, fieldName)) {
27421
27438
  if (state.traceEnabled) {
@@ -27637,9 +27654,11 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
27637
27654
  if (result && result.resolvedModule)
27638
27655
  (_b = perfLogger) == null ? void 0 : _b.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`);
27639
27656
  (_c = perfLogger) == null ? void 0 : _c.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null");
27640
- cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
27641
- if (!isExternalModuleNameRelative(moduleName)) {
27642
- cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
27657
+ if (cache && !cache.isReadonly) {
27658
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
27659
+ if (!isExternalModuleNameRelative(moduleName)) {
27660
+ cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
27661
+ }
27643
27662
  }
27644
27663
  }
27645
27664
  if (traceEnabled) {
@@ -27923,6 +27942,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
27923
27942
  affectingLocations,
27924
27943
  diagnostics,
27925
27944
  state,
27945
+ cache,
27926
27946
  legacyResult
27927
27947
  );
27928
27948
  function tryResolve(extensions2, state2) {
@@ -28186,7 +28206,7 @@ function getVersionPathsOfPackageJsonInfo(packageJsonInfo, state) {
28186
28206
  return packageJsonInfo.contents.versionPaths || void 0;
28187
28207
  }
28188
28208
  function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
28189
- var _a, _b, _c, _d, _e, _f, _g, _h;
28209
+ var _a, _b, _c, _d, _e, _f;
28190
28210
  const { host, traceEnabled } = state;
28191
28211
  const packageJsonPath = combinePaths(packageDirectory, "package.json");
28192
28212
  if (onlyRecordFailures) {
@@ -28214,15 +28234,17 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
28214
28234
  trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath);
28215
28235
  }
28216
28236
  const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } };
28217
- (_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result);
28218
- (_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath);
28237
+ if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly)
28238
+ state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, result);
28239
+ (_e = state.affectingLocations) == null ? void 0 : _e.push(packageJsonPath);
28219
28240
  return result;
28220
28241
  } else {
28221
28242
  if (directoryExists && traceEnabled) {
28222
28243
  trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
28223
28244
  }
28224
- (_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists);
28225
- (_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath);
28245
+ if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly)
28246
+ state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, directoryExists);
28247
+ (_f = state.failedLookupLocations) == null ? void 0 : _f.push(packageJsonPath);
28226
28248
  }
28227
28249
  }
28228
28250
  function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
@@ -28999,7 +29021,8 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
28999
29021
  failedLookupLocations,
29000
29022
  affectingLocations,
29001
29023
  diagnostics,
29002
- state
29024
+ state,
29025
+ cache
29003
29026
  );
29004
29027
  function tryResolve(extensions) {
29005
29028
  const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);