diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go
index 9396bc89d5..4ea23d0218 100644
--- a/internal/compiler/fileloader.go
+++ b/internal/compiler/fileloader.go
@@ -34,6 +34,9 @@ type fileLoader struct {
projectReferenceFileMapper *projectReferenceFileMapper
dtsDirectories collections.Set[tspath.Path]
+
+ pathForLibFileCache collections.SyncMap[string, string]
+ pathForLibFileResolutions collections.SyncMap[tspath.Path, module.ModeAwareCache[*module.ResolvedModule]]
}
type processedFiles struct {
@@ -59,7 +62,6 @@ type jsxRuntimeImportSpecifier struct {
func processAllProgramFiles(
opts ProgramOptions,
- libs []string,
singleThreaded bool,
) processedFiles {
compilerOptions := opts.Config.CompilerOptions()
@@ -83,11 +85,27 @@ func processAllProgramFiles(
projectReferenceParseTasks: &fileLoaderWorker[*projectReferenceParseTask]{
wg: core.NewWorkGroup(singleThreaded),
},
- rootTasks: make([]*parseTask, 0, len(rootFiles)+len(libs)),
+ rootTasks: make([]*parseTask, 0, len(rootFiles)+len(compilerOptions.Lib)),
supportedExtensions: core.Flatten(tsoptions.GetSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions)),
}
loader.addProjectReferenceTasks()
loader.resolver = module.NewResolver(loader.projectReferenceFileMapper.host, compilerOptions, opts.TypingsLocation, opts.ProjectName)
+
+ var libs []string
+ if compilerOptions.NoLib.IsFalseOrUnknown() {
+ if compilerOptions.Lib == nil {
+ name := tsoptions.GetDefaultLibFileName(compilerOptions)
+ libs = append(libs, loader.pathForLibFile(name))
+ } else {
+ for _, lib := range compilerOptions.Lib {
+ if name, ok := tsoptions.GetLibFileName(lib); ok {
+ libs = append(libs, loader.pathForLibFile(name))
+ }
+ // !!! error on unknown name
+ }
+ }
+ }
+
loader.addRootTasks(rootFiles, false)
loader.addRootTasks(libs, true)
loader.addAutomaticTypeDirectiveTasks()
@@ -105,7 +123,7 @@ func processAllProgramFiles(
libFiles := make([]*ast.SourceFile, 0, totalFileCount) // totalFileCount here since we append files to it later to construct the final list
filesByPath := make(map[tspath.Path]*ast.SourceFile, totalFileCount)
- resolvedModules := make(map[tspath.Path]module.ModeAwareCache[*module.ResolvedModule], totalFileCount)
+ resolvedModules := make(map[tspath.Path]module.ModeAwareCache[*module.ResolvedModule], totalFileCount+1)
typeResolutionsInFile := make(map[tspath.Path]module.ModeAwareCache[*module.ResolvedTypeReferenceDirective], totalFileCount)
sourceFileMetaDatas := make(map[tspath.Path]ast.SourceFileMetaData, totalFileCount)
var jsxRuntimeImportSpecifiers map[tspath.Path]*jsxRuntimeImportSpecifier
@@ -162,6 +180,11 @@ func processAllProgramFiles(
allFiles := append(libFiles, files...)
+ loader.pathForLibFileResolutions.Range(func(key tspath.Path, value module.ModeAwareCache[*module.ResolvedModule]) bool {
+ resolvedModules[key] = value
+ return true
+ })
+
return processedFiles{
resolver: loader.resolver,
files: allFiles,
@@ -463,6 +486,55 @@ func (p *fileLoader) createSyntheticImport(text string, file *ast.SourceFile) *a
return externalHelpersModuleReference
}
+func (p *fileLoader) pathForLibFile(name string) string {
+ if cached, ok := p.pathForLibFileCache.Load(name); ok {
+ return cached
+ }
+
+ path := tspath.CombinePaths(p.defaultLibraryPath, name)
+ if p.opts.Config.CompilerOptions().LibReplacement.IsTrue() {
+ libraryName := getLibraryNameFromLibFileName(name)
+ resolveFrom := getInferredLibraryNameResolveFrom(p.opts.Config.CompilerOptions(), p.opts.Host.GetCurrentDirectory(), name)
+ resolution := p.resolver.ResolveModuleName(libraryName, resolveFrom, core.ModuleKindCommonJS, nil)
+ if resolution.IsResolved() {
+ path = resolution.ResolvedFileName
+ p.pathForLibFileResolutions.LoadOrStore(p.toPath(resolveFrom), module.ModeAwareCache[*module.ResolvedModule]{
+ module.ModeAwareCacheKey{Name: libraryName, Mode: core.ModuleKindCommonJS}: resolution,
+ })
+ }
+ }
+
+ path, _ = p.pathForLibFileCache.LoadOrStore(name, path)
+ return path
+}
+
+func getLibraryNameFromLibFileName(libFileName string) string {
+ // Support resolving to lib.dom.d.ts -> @typescript/lib-dom, and
+ // lib.dom.iterable.d.ts -> @typescript/lib-dom/iterable
+ // lib.es2015.symbol.wellknown.d.ts -> @typescript/lib-es2015/symbol-wellknown
+ components := strings.Split(libFileName, ".")
+ var path string
+ if len(components) > 1 {
+ path = components[1]
+ }
+ i := 2
+ for i < len(components) && components[i] != "" && components[i] != "d" {
+ path += core.IfElse(i == 2, "/", "-") + components[i]
+ i++
+ }
+ return "@typescript/lib-" + path
+}
+
+func getInferredLibraryNameResolveFrom(options *core.CompilerOptions, currentDirectory string, libFileName string) string {
+ var containingDirectory string
+ if options.ConfigFilePath != "" {
+ containingDirectory = tspath.GetDirectoryPath(options.ConfigFilePath)
+ } else {
+ containingDirectory = currentDirectory
+ }
+ return tspath.CombinePaths(containingDirectory, "__lib_node_modules_lookup_"+libFileName+"__.ts")
+}
+
type resolution struct {
node *ast.Node
resolvedModule *module.ResolvedModule
diff --git a/internal/compiler/parsetask.go b/internal/compiler/parsetask.go
index 75b2e63825..ebb6fdcce3 100644
--- a/internal/compiler/parsetask.go
+++ b/internal/compiler/parsetask.go
@@ -77,11 +77,9 @@ func (t *parseTask) load(loader *fileLoader) {
if compilerOptions.NoLib != core.TSTrue {
for _, lib := range file.LibReferenceDirectives {
- name, ok := tsoptions.GetLibFileName(lib.FileName)
- if !ok {
- continue
+ if name, ok := tsoptions.GetLibFileName(lib.FileName); ok {
+ t.addSubTask(resolvedRef{fileName: loader.pathForLibFile(name)}, true)
}
- t.addSubTask(resolvedRef{fileName: tspath.CombinePaths(loader.defaultLibraryPath, name)}, true)
}
}
diff --git a/internal/compiler/program.go b/internal/compiler/program.go
index 7cddb367a2..bc87837fca 100644
--- a/internal/compiler/program.go
+++ b/internal/compiler/program.go
@@ -172,37 +172,9 @@ func (p *Program) GetSourceFileFromReference(origin *ast.SourceFile, ref *ast.Fi
}
func NewProgram(opts ProgramOptions) *Program {
- p := &Program{
- opts: opts,
- }
- compilerOptions := p.opts.Config.CompilerOptions()
- if compilerOptions == nil {
- panic("compiler options required")
- }
- if p.opts.Host == nil {
- panic("host required")
- }
+ p := &Program{opts: opts}
p.initCheckerPool()
-
- var libs []string
-
- if compilerOptions.NoLib != core.TSTrue {
- if compilerOptions.Lib == nil {
- name := tsoptions.GetDefaultLibFileName(compilerOptions)
- libs = append(libs, tspath.CombinePaths(p.Host().DefaultLibraryPath(), name))
- } else {
- for _, lib := range compilerOptions.Lib {
- name, ok := tsoptions.GetLibFileName(lib)
- if ok {
- libs = append(libs, tspath.CombinePaths(p.Host().DefaultLibraryPath(), name))
- }
- // !!! error on unknown name
- }
- }
- }
-
- p.processedFiles = processAllProgramFiles(p.opts, libs, p.singleThreaded())
-
+ p.processedFiles = processAllProgramFiles(p.opts, p.singleThreaded())
return p
}
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.errors.txt b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.errors.txt
new file mode 100644
index 0000000000..be8ceec77d
--- /dev/null
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.errors.txt
@@ -0,0 +1,15 @@
+index.ts(6,1): error TS2304: Cannot find name 'window'.
+
+
+==== /node_modules/@typescript/lib-dom/index.d.ts (0 errors) ====
+ interface ABC { abc: string }
+==== index.ts (1 errors) ====
+ ///
+ const a: ABC = { abc: "Hello" }
+
+ // This should fail because libdom has been replaced
+ // by the module above ^
+ window.localStorage
+ ~~~~~~
+!!! error TS2304: Cannot find name 'window'.
+
\ No newline at end of file
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.errors.txt.diff
deleted file mode 100644
index af3c535b90..0000000000
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.errors.txt.diff
+++ /dev/null
@@ -1,19 +0,0 @@
---- old.libTypeScriptOverrideSimple.errors.txt
-+++ new.libTypeScriptOverrideSimple.errors.txt
-@@= skipped -0, +0 lines =@@
--index.ts(6,1): error TS2304: Cannot find name 'window'.
--
--
--==== /node_modules/@typescript/lib-dom/index.d.ts (0 errors) ====
-- interface ABC { abc: string }
--==== index.ts (1 errors) ====
-- ///
-- const a: ABC = { abc: "Hello" }
--
-- // This should fail because libdom has been replaced
-- // by the module above ^
-- window.localStorage
-- ~~~~~~
--!!! error TS2304: Cannot find name 'window'.
--
-+
\ No newline at end of file
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.symbols b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.symbols
index c519a404a8..b11a6ed52e 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.symbols
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.symbols
@@ -15,7 +15,4 @@ const a: ABC = { abc: "Hello" }
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage
->window.localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
->window : Symbol(window, Decl(lib.dom.d.ts, --, --))
->localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.symbols.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.symbols.diff
index 03570078e6..54fc22c1be 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.symbols.diff
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.symbols.diff
@@ -8,11 +8,4 @@
+>abc : Symbol(abc, Decl(index.d.ts, 0, 15))
=== index.ts ===
- ///
-@@= skipped -12, +12 lines =@@
- // This should fail because libdom has been replaced
- // by the module above ^
- window.localStorage
-+>window.localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
-+>window : Symbol(window, Decl(lib.dom.d.ts, --, --))
-+>localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+ ///
\ No newline at end of file
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.types b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.types
index 4dcbc40564..889c3ca55c 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.types
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.types
@@ -15,7 +15,7 @@ const a: ABC = { abc: "Hello" }
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage
->window.localStorage : Storage
->window : Window & typeof globalThis
->localStorage : Storage
+>window.localStorage : any
+>window : any
+>localStorage : any
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.types.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.types.diff
deleted file mode 100644
index f29170c439..0000000000
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimple.types.diff
+++ /dev/null
@@ -1,12 +0,0 @@
---- old.libTypeScriptOverrideSimple.types
-+++ new.libTypeScriptOverrideSimple.types
-@@= skipped -14, +14 lines =@@
- // This should fail because libdom has been replaced
- // by the module above ^
- window.localStorage
-->window.localStorage : any
-->window : any
-->localStorage : any
-+>window.localStorage : Storage
-+>window : Window & typeof globalThis
-+>localStorage : Storage
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.errors.txt b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.errors.txt
index a01ceeddd2..d6f5889d4e 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.errors.txt
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.errors.txt
@@ -1,4 +1,4 @@
-/somepath/index.ts(2,10): error TS2304: Cannot find name 'ABC'.
+/somepath/index.ts(6,1): error TS2304: Cannot find name 'window'.
==== /somepath/tsconfig.json (0 errors) ====
@@ -6,12 +6,12 @@
==== /somepath/index.ts (1 errors) ====
///
const a: ABC = { abc: "Hello" }
- ~~~
-!!! error TS2304: Cannot find name 'ABC'.
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage
+ ~~~~~~
+!!! error TS2304: Cannot find name 'window'.
==== /somepath/node_modules/@typescript/lib-dom/index.d.ts (0 errors) ====
interface ABC { abc: string }
\ No newline at end of file
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.errors.txt.diff
deleted file mode 100644
index 81f51159bf..0000000000
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.errors.txt.diff
+++ /dev/null
@@ -1,23 +0,0 @@
---- old.libTypeScriptOverrideSimpleConfig.errors.txt
-+++ new.libTypeScriptOverrideSimpleConfig.errors.txt
-@@= skipped -0, +0 lines =@@
--/somepath/index.ts(6,1): error TS2304: Cannot find name 'window'.
-+/somepath/index.ts(2,10): error TS2304: Cannot find name 'ABC'.
-
-
- ==== /somepath/tsconfig.json (0 errors) ====
-@@= skipped -5, +5 lines =@@
- ==== /somepath/index.ts (1 errors) ====
- ///
- const a: ABC = { abc: "Hello" }
-+ ~~~
-+!!! error TS2304: Cannot find name 'ABC'.
-
- // This should fail because libdom has been replaced
- // by the module above ^
- window.localStorage
-- ~~~~~~
--!!! error TS2304: Cannot find name 'window'.
-
- ==== /somepath/node_modules/@typescript/lib-dom/index.d.ts (0 errors) ====
- interface ABC { abc: string }
\ No newline at end of file
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.symbols b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.symbols
index 1f13eb596d..197ea8d111 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.symbols
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.symbols
@@ -4,13 +4,15 @@
///
const a: ABC = { abc: "Hello" }
>a : Symbol(a, Decl(index.ts, 1, 5))
->ABC : Symbol(ABC)
+>ABC : Symbol(ABC, Decl(index.d.ts, 0, 0))
>abc : Symbol(abc, Decl(index.ts, 1, 16))
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage
->window.localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
->window : Symbol(window, Decl(lib.dom.d.ts, --, --))
->localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+
+=== /somepath/node_modules/@typescript/lib-dom/index.d.ts ===
+interface ABC { abc: string }
+>ABC : Symbol(ABC, Decl(index.d.ts, 0, 0))
+>abc : Symbol(abc, Decl(index.d.ts, 0, 15))
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.symbols.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.symbols.diff
index 70c5c86ab3..7c58e28053 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.symbols.diff
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.symbols.diff
@@ -1,21 +1,8 @@
--- old.libTypeScriptOverrideSimpleConfig.symbols
+++ new.libTypeScriptOverrideSimpleConfig.symbols
-@@= skipped -3, +3 lines =@@
- ///
- const a: ABC = { abc: "Hello" }
- >a : Symbol(a, Decl(index.ts, 1, 5))
-->ABC : Symbol(ABC, Decl(index.d.ts, 0, 0))
-+>ABC : Symbol(ABC)
- >abc : Symbol(abc, Decl(index.ts, 1, 16))
-
- // This should fail because libdom has been replaced
- // by the module above ^
- window.localStorage
--
--=== /somepath/node_modules/@typescript/lib-dom/index.d.ts ===
--interface ABC { abc: string }
-->ABC : Symbol(ABC, Decl(index.d.ts, 0, 0))
+@@= skipped -13, +13 lines =@@
+ === /somepath/node_modules/@typescript/lib-dom/index.d.ts ===
+ interface ABC { abc: string }
+ >ABC : Symbol(ABC, Decl(index.d.ts, 0, 0))
->abc : Symbol(ABC.abc, Decl(index.d.ts, 0, 15))
-+>window.localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
-+>window : Symbol(window, Decl(lib.dom.d.ts, --, --))
-+>localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
++>abc : Symbol(abc, Decl(index.d.ts, 0, 15))
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.types b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.types
index 3dc706457b..57412e40f6 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.types
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.types
@@ -11,7 +11,11 @@ const a: ABC = { abc: "Hello" }
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage
->window.localStorage : Storage
->window : Window & typeof globalThis
->localStorage : Storage
+>window.localStorage : any
+>window : any
+>localStorage : any
+
+=== /somepath/node_modules/@typescript/lib-dom/index.d.ts ===
+interface ABC { abc: string }
+>abc : string
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.types.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.types.diff
deleted file mode 100644
index 08ce51b4ad..0000000000
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptOverrideSimpleConfig.types.diff
+++ /dev/null
@@ -1,16 +0,0 @@
---- old.libTypeScriptOverrideSimpleConfig.types
-+++ new.libTypeScriptOverrideSimpleConfig.types
-@@= skipped -10, +10 lines =@@
- // This should fail because libdom has been replaced
- // by the module above ^
- window.localStorage
-->window.localStorage : any
-->window : any
-->localStorage : any
--
--=== /somepath/node_modules/@typescript/lib-dom/index.d.ts ===
--interface ABC { abc: string }
-->abc : string
-+>window.localStorage : Storage
-+>window : Window & typeof globalThis
-+>localStorage : Storage
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.errors.txt b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.errors.txt
new file mode 100644
index 0000000000..c331dcd51c
--- /dev/null
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.errors.txt
@@ -0,0 +1,17 @@
+index.ts(6,1): error TS2304: Cannot find name 'window'.
+
+
+==== /node_modules/@typescript/lib-dom/index.d.ts (0 errors) ====
+ // NOOP
+==== /node_modules/@typescript/lib-dom/iterable.d.ts (0 errors) ====
+ interface DOMIterable { abc: string }
+==== index.ts (1 errors) ====
+ ///
+ const a: DOMIterable = { abc: "Hello" }
+
+ // This should fail because libdom has been replaced
+ // by the module above ^
+ window.localStorage
+ ~~~~~~
+!!! error TS2304: Cannot find name 'window'.
+
\ No newline at end of file
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.errors.txt.diff
deleted file mode 100644
index 695cb00b7f..0000000000
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.errors.txt.diff
+++ /dev/null
@@ -1,21 +0,0 @@
---- old.libTypeScriptSubfileResolving.errors.txt
-+++ new.libTypeScriptSubfileResolving.errors.txt
-@@= skipped -0, +0 lines =@@
--index.ts(6,1): error TS2304: Cannot find name 'window'.
--
--
--==== /node_modules/@typescript/lib-dom/index.d.ts (0 errors) ====
-- // NOOP
--==== /node_modules/@typescript/lib-dom/iterable.d.ts (0 errors) ====
-- interface DOMIterable { abc: string }
--==== index.ts (1 errors) ====
-- ///
-- const a: DOMIterable = { abc: "Hello" }
--
-- // This should fail because libdom has been replaced
-- // by the module above ^
-- window.localStorage
-- ~~~~~~
--!!! error TS2304: Cannot find name 'window'.
--
-+
\ No newline at end of file
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.symbols b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.symbols
index 4cbc349668..6b5812de94 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.symbols
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.symbols
@@ -18,7 +18,4 @@ const a: DOMIterable = { abc: "Hello" }
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage
->window.localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
->window : Symbol(window, Decl(lib.dom.d.ts, --, --))
->localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.symbols.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.symbols.diff
index 56e4932d7e..4f6ebe5bf1 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.symbols.diff
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.symbols.diff
@@ -8,11 +8,4 @@
+>abc : Symbol(abc, Decl(iterable.d.ts, 0, 23))
=== index.ts ===
- ///
-@@= skipped -12, +12 lines =@@
- // This should fail because libdom has been replaced
- // by the module above ^
- window.localStorage
-+>window.localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
-+>window : Symbol(window, Decl(lib.dom.d.ts, --, --))
-+>localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+ ///
\ No newline at end of file
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.types b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.types
index 27ec58ce91..47b68d2838 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.types
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.types
@@ -18,7 +18,7 @@ const a: DOMIterable = { abc: "Hello" }
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage
->window.localStorage : Storage
->window : Window & typeof globalThis
->localStorage : Storage
+>window.localStorage : any
+>window : any
+>localStorage : any
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.types.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.types.diff
deleted file mode 100644
index 711e3e2d39..0000000000
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolving.types.diff
+++ /dev/null
@@ -1,12 +0,0 @@
---- old.libTypeScriptSubfileResolving.types
-+++ new.libTypeScriptSubfileResolving.types
-@@= skipped -17, +17 lines =@@
- // This should fail because libdom has been replaced
- // by the module above ^
- window.localStorage
-->window.localStorage : any
-->window : any
-->localStorage : any
-+>window.localStorage : Storage
-+>window : Window & typeof globalThis
-+>localStorage : Storage
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.errors.txt b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.errors.txt
index eb5ffb7747..c3a3fe70a6 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.errors.txt
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.errors.txt
@@ -1,4 +1,4 @@
-/somepath/index.ts(2,10): error TS2304: Cannot find name 'DOMIterable'.
+/somepath/index.ts(6,1): error TS2304: Cannot find name 'window'.
==== /somepath/tsconfig.json (0 errors) ====
@@ -6,12 +6,12 @@
==== /somepath/index.ts (1 errors) ====
///
const a: DOMIterable = { abc: "Hello" }
- ~~~~~~~~~~~
-!!! error TS2304: Cannot find name 'DOMIterable'.
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage
+ ~~~~~~
+!!! error TS2304: Cannot find name 'window'.
==== /somepath/node_modules/@typescript/lib-dom/index.d.ts (0 errors) ====
// NOOP
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.errors.txt.diff
deleted file mode 100644
index 84899e77b2..0000000000
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.errors.txt.diff
+++ /dev/null
@@ -1,23 +0,0 @@
---- old.libTypeScriptSubfileResolvingConfig.errors.txt
-+++ new.libTypeScriptSubfileResolvingConfig.errors.txt
-@@= skipped -0, +0 lines =@@
--/somepath/index.ts(6,1): error TS2304: Cannot find name 'window'.
-+/somepath/index.ts(2,10): error TS2304: Cannot find name 'DOMIterable'.
-
-
- ==== /somepath/tsconfig.json (0 errors) ====
-@@= skipped -5, +5 lines =@@
- ==== /somepath/index.ts (1 errors) ====
- ///
- const a: DOMIterable = { abc: "Hello" }
-+ ~~~~~~~~~~~
-+!!! error TS2304: Cannot find name 'DOMIterable'.
-
- // This should fail because libdom has been replaced
- // by the module above ^
- window.localStorage
-- ~~~~~~
--!!! error TS2304: Cannot find name 'window'.
-
- ==== /somepath/node_modules/@typescript/lib-dom/index.d.ts (0 errors) ====
- // NOOP
\ No newline at end of file
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.symbols b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.symbols
index 6bf318bfc1..17e830100c 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.symbols
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.symbols
@@ -4,13 +4,18 @@
///
const a: DOMIterable = { abc: "Hello" }
>a : Symbol(a, Decl(index.ts, 1, 5))
->DOMIterable : Symbol(DOMIterable)
+>DOMIterable : Symbol(DOMIterable, Decl(iterable.d.ts, 0, 0))
>abc : Symbol(abc, Decl(index.ts, 1, 24))
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage
->window.localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
->window : Symbol(window, Decl(lib.dom.d.ts, --, --))
->localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+
+=== /somepath/node_modules/@typescript/lib-dom/index.d.ts ===
+
+// NOOP
+=== /somepath/node_modules/@typescript/lib-dom/iterable.d.ts ===
+interface DOMIterable { abc: string }
+>DOMIterable : Symbol(DOMIterable, Decl(iterable.d.ts, 0, 0))
+>abc : Symbol(abc, Decl(iterable.d.ts, 0, 23))
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.symbols.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.symbols.diff
index 79be01d78e..8c56fdeced 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.symbols.diff
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.symbols.diff
@@ -1,24 +1,8 @@
--- old.libTypeScriptSubfileResolvingConfig.symbols
+++ new.libTypeScriptSubfileResolvingConfig.symbols
-@@= skipped -3, +3 lines =@@
- ///
- const a: DOMIterable = { abc: "Hello" }
- >a : Symbol(a, Decl(index.ts, 1, 5))
-->DOMIterable : Symbol(DOMIterable, Decl(iterable.d.ts, 0, 0))
-+>DOMIterable : Symbol(DOMIterable)
- >abc : Symbol(abc, Decl(index.ts, 1, 24))
-
- // This should fail because libdom has been replaced
- // by the module above ^
- window.localStorage
--
--=== /somepath/node_modules/@typescript/lib-dom/index.d.ts ===
--
--// NOOP
--=== /somepath/node_modules/@typescript/lib-dom/iterable.d.ts ===
--interface DOMIterable { abc: string }
-->DOMIterable : Symbol(DOMIterable, Decl(iterable.d.ts, 0, 0))
+@@= skipped -16, +16 lines =@@
+ === /somepath/node_modules/@typescript/lib-dom/iterable.d.ts ===
+ interface DOMIterable { abc: string }
+ >DOMIterable : Symbol(DOMIterable, Decl(iterable.d.ts, 0, 0))
->abc : Symbol(DOMIterable.abc, Decl(iterable.d.ts, 0, 23))
-+>window.localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
-+>window : Symbol(window, Decl(lib.dom.d.ts, --, --))
-+>localStorage : Symbol(localStorage, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
++>abc : Symbol(abc, Decl(iterable.d.ts, 0, 23))
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.types b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.types
index 646067073d..f2e4e27f11 100644
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.types
+++ b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.types
@@ -11,7 +11,14 @@ const a: DOMIterable = { abc: "Hello" }
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage
->window.localStorage : Storage
->window : Window & typeof globalThis
->localStorage : Storage
+>window.localStorage : any
+>window : any
+>localStorage : any
+
+=== /somepath/node_modules/@typescript/lib-dom/index.d.ts ===
+
+// NOOP
+=== /somepath/node_modules/@typescript/lib-dom/iterable.d.ts ===
+interface DOMIterable { abc: string }
+>abc : string
diff --git a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.types.diff b/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.types.diff
deleted file mode 100644
index a970dcb08d..0000000000
--- a/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.types.diff
+++ /dev/null
@@ -1,19 +0,0 @@
---- old.libTypeScriptSubfileResolvingConfig.types
-+++ new.libTypeScriptSubfileResolvingConfig.types
-@@= skipped -10, +10 lines =@@
- // This should fail because libdom has been replaced
- // by the module above ^
- window.localStorage
-->window.localStorage : any
-->window : any
-->localStorage : any
--
--=== /somepath/node_modules/@typescript/lib-dom/index.d.ts ===
--
--// NOOP
--=== /somepath/node_modules/@typescript/lib-dom/iterable.d.ts ===
--interface DOMIterable { abc: string }
-->abc : string
-+>window.localStorage : Storage
-+>window : Window & typeof globalThis
-+>localStorage : Storage