Skip to content

Commit 92d37c3

Browse files
Merge pull request #5511 from Microsoft/skipDefaultLibCheckWithNoDefaultLib
Skip files with no-default-lib when '--skipDefaultLibCheck' and '--noLib' are used
2 parents 5d9e7e1 + fb192e2 commit 92d37c3

File tree

6 files changed

+12
-30
lines changed

6 files changed

+12
-30
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14086,8 +14086,12 @@ namespace ts {
1408614086
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
1408714087
// Check whether the file has declared it is the default lib,
1408814088
// and whether the user has specifically chosen to avoid checking it.
14089-
if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) {
14090-
return;
14089+
if (compilerOptions.skipDefaultLibCheck) {
14090+
// If the user specified '--noLib' and a file has a '/// <reference no-default-lib="true"/>',
14091+
// then we should treat that file as a default lib.
14092+
if (node.hasNoDefaultLib) {
14093+
return;
14094+
}
1409114095
}
1409214096

1409314097
// Grammar checking

src/compiler/program.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,6 @@ namespace ts {
833833
processImportedModules(file, basePath);
834834

835835
if (isDefaultLib) {
836-
file.isDefaultLib = true;
837836
files.unshift(file);
838837
}
839838
else {

src/compiler/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,6 @@ namespace ts {
12851285
// The first node that causes this file to be an external module
12861286
/* @internal */ externalModuleIndicator: Node;
12871287

1288-
/* @internal */ isDefaultLib: boolean;
12891288
/* @internal */ identifiers: Map<string>;
12901289
/* @internal */ nodeCount: number;
12911290
/* @internal */ identifierCount: number;

tests/baselines/reference/typeCheckTypeArgument.errors.txt

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
1-
error TS2318: Cannot find global type 'Array'.
2-
error TS2318: Cannot find global type 'Boolean'.
3-
error TS2318: Cannot find global type 'Function'.
4-
error TS2318: Cannot find global type 'IArguments'.
5-
error TS2318: Cannot find global type 'Number'.
6-
error TS2318: Cannot find global type 'Object'.
7-
error TS2318: Cannot find global type 'RegExp'.
8-
error TS2318: Cannot find global type 'String'.
9-
tests/cases/compiler/typeCheckTypeArgument.ts(3,19): error TS2304: Cannot find name 'UNKNOWN'.
10-
tests/cases/compiler/typeCheckTypeArgument.ts(5,26): error TS2304: Cannot find name 'UNKNOWN'.
11-
tests/cases/compiler/typeCheckTypeArgument.ts(7,21): error TS2304: Cannot find name 'UNKNOWN'.
12-
tests/cases/compiler/typeCheckTypeArgument.ts(9,24): error TS2304: Cannot find name 'UNKNOWN'.
13-
tests/cases/compiler/typeCheckTypeArgument.ts(12,22): error TS2304: Cannot find name 'UNKNOWN'.
14-
tests/cases/compiler/typeCheckTypeArgument.ts(15,13): error TS2304: Cannot find name 'UNKNOWN'.
1+
tests/cases/compiler/typeCheckTypeArgument.ts(2,19): error TS2304: Cannot find name 'UNKNOWN'.
2+
tests/cases/compiler/typeCheckTypeArgument.ts(4,26): error TS2304: Cannot find name 'UNKNOWN'.
3+
tests/cases/compiler/typeCheckTypeArgument.ts(6,21): error TS2304: Cannot find name 'UNKNOWN'.
4+
tests/cases/compiler/typeCheckTypeArgument.ts(8,24): error TS2304: Cannot find name 'UNKNOWN'.
5+
tests/cases/compiler/typeCheckTypeArgument.ts(11,22): error TS2304: Cannot find name 'UNKNOWN'.
6+
tests/cases/compiler/typeCheckTypeArgument.ts(14,13): error TS2304: Cannot find name 'UNKNOWN'.
157

168

17-
!!! error TS2318: Cannot find global type 'Array'.
18-
!!! error TS2318: Cannot find global type 'Boolean'.
19-
!!! error TS2318: Cannot find global type 'Function'.
20-
!!! error TS2318: Cannot find global type 'IArguments'.
21-
!!! error TS2318: Cannot find global type 'Number'.
22-
!!! error TS2318: Cannot find global type 'Object'.
23-
!!! error TS2318: Cannot find global type 'RegExp'.
24-
!!! error TS2318: Cannot find global type 'String'.
259
==== tests/cases/compiler/typeCheckTypeArgument.ts (6 errors) ====
26-
/// <reference no-default-lib="true"/>
2710

2811
var f: <T extends UNKNOWN>() => void;
2912
~~~~~~~

tests/baselines/reference/typeCheckTypeArgument.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//// [typeCheckTypeArgument.ts]
2-
/// <reference no-default-lib="true"/>
32

43
var f: <T extends UNKNOWN>() => void;
54

@@ -16,7 +15,6 @@ class Foo2 {
1615
(<T extends UNKNOWN>(a) => { });
1716

1817
//// [typeCheckTypeArgument.js]
19-
/// <reference no-default-lib="true"/>
2018
var f;
2119
var Foo = (function () {
2220
function Foo() {

tests/cases/compiler/typeCheckTypeArgument.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference no-default-lib="true"/>
21

32
var f: <T extends UNKNOWN>() => void;
43

0 commit comments

Comments
 (0)