Skip to content

Skip files with no-default-lib when '--skipDefaultLibCheck' are used #5511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 9, 2015
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14058,8 +14058,16 @@ namespace ts {
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
// Check whether the file has declared it is the default lib,
// and whether the user has specifically chosen to avoid checking it.
if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) {
return;
if (compilerOptions.skipDefaultLibCheck) {
if (node.isDefaultLib) {
return;
}

// If the user specified '--noLib' and a file has a '/// <reference no-default-lib="true"/>',
// then we should treat that file as a default lib.
if (compilerOptions.noLib && node.hasNoDefaultLib) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not think you need "compilerOptions.noLib" check. having a file with the NoDefaultLib comment is equivalent to --noLib.

I propose we simplify this whole thing, and remove sourceFile.isDefaultLib, as it is not clear why we have it. we should have one concept, is this file a default lib, and that is determined by the flag, the lib.d.ts we add has the flag anyways, so things should just work without the additional flag we are passing through.

we can change our test, to not include the /// comment. and just pass --noLib instead, this way it still type checks, but does not trigger this condition.

return;
}
}

// Grammar checking
Expand Down