Skip to content

Commit 11b1501

Browse files
committed
Do not process library reference directives with noLib set.
When a user sets `noLib`, this indicates that they will supply their own list of `lib*.d.ts` files as part of input sources. In this situation, TypeScript should not try to resolve library reference directives. This avoids a problem where TypeScript loads a file that e.g. contains `/// <reference lib="es2015.symbol"/>`. Previously, TypeScript would use its builtin ts.libMap and attempt to load builtin libraries from the TypeScript installation, instead of respecting the user-supplied set of libraries.
1 parent aba0b70 commit 11b1501

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/compiler/program.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,8 +2227,9 @@ namespace ts {
22272227
processReferencedFiles(file, isDefaultLib);
22282228
processTypeReferenceDirectives(file);
22292229
}
2230-
2231-
processLibReferenceDirectives(file);
2230+
if (!options.noLib) {
2231+
processLibReferenceDirectives(file);
2232+
}
22322233

22332234
modulesWithElidedImports.set(file.path, false);
22342235
processImportedModules(file);
@@ -2315,8 +2316,10 @@ namespace ts {
23152316
processReferencedFiles(file, isDefaultLib);
23162317
processTypeReferenceDirectives(file);
23172318
}
2319+
if (!options.noLib) {
2320+
processLibReferenceDirectives(file);
2321+
}
23182322

2319-
processLibReferenceDirectives(file);
23202323

23212324
// always process imported modules to record module name resolutions
23222325
processImportedModules(file);

0 commit comments

Comments
 (0)