Skip to content

Commit f250955

Browse files
committed
Implement --skipLibCheck flag in tsbuild
Summary: Many large composite projects rely on skipLibCheck to improve build times. However, skipLibCheck does introduce some risk that projects miss typescript errors in new node module versions they install. This is in response to Issues microsoft#45691, microsoft#25613, and microsoft#41185 Test Plan: New tsbuild unit test scenario that tests overriding the skipLibCheck value with a flag. Validated with verbose output that the actual build overrode the value in the tsconfig.json file.
1 parent 5daa6f4 commit f250955

File tree

25 files changed

+372
-93
lines changed

25 files changed

+372
-93
lines changed

src/compiler/commandLineParser.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,13 @@ namespace ts {
290290
description: Diagnostics.Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit,
291291
defaultValueDescription: Diagnostics.Platform_specific
292292
},
293+
{
294+
name: "skipLibCheck",
295+
type: "boolean",
296+
category: Diagnostics.Completeness,
297+
description: Diagnostics.Skip_type_checking_all_d_ts_files,
298+
defaultValueDescription: "false"
299+
},
293300
];
294301

295302
/* @internal */
@@ -1094,13 +1101,6 @@ namespace ts {
10941101
description: Diagnostics.Specify_the_output_directory_for_generated_declaration_files,
10951102
defaultValueDescription: "n/a"
10961103
},
1097-
{
1098-
name: "skipLibCheck",
1099-
type: "boolean",
1100-
category: Diagnostics.Completeness,
1101-
description: Diagnostics.Skip_type_checking_all_d_ts_files,
1102-
defaultValueDescription: "false"
1103-
},
11041104
{
11051105
name: "allowUnusedLabels",
11061106
type: "boolean",

src/compiler/tsbuildPublic.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace ts {
1818
/*@internal*/ pretty?: boolean;
1919
incremental?: boolean;
2020
assumeChangesOnlyAffectDirectDependencies?: boolean;
21+
skipLibCheck?: boolean;
2122

2223
traceResolution?: boolean;
2324
/* @internal */ diagnostics?: boolean;

src/testRunner/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
"unittests/tsbuild/referencesWithRootDirInParent.ts",
140140
"unittests/tsbuild/resolveJsonModule.ts",
141141
"unittests/tsbuild/sample.ts",
142+
"unittests/tsbuild/skipLibCheck.ts",
142143
"unittests/tsbuild/transitiveReferences.ts",
143144
"unittests/tsbuildWatch/configFileErrors.ts",
144145
"unittests/tsbuildWatch/demo.ts",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace ts {
2+
describe("unittests:: tsbuild:: on project with skipLibCheck set to true", () => {
3+
let projFs: vfs.FileSystem;
4+
before(() => {
5+
projFs = loadProjectFromDisk("tests/projects/skipLibCheck");
6+
});
7+
after(() => {
8+
projFs = undefined!;
9+
});
10+
11+
verifyTsc({
12+
subScenario: `program options include skipLibCheck`,
13+
fs: () => projFs,
14+
scenario: "skipLibCheck",
15+
commandLineArgs: ["--b", "/src", "--verbose"],
16+
});
17+
verifyTsc({
18+
subScenario: `command line argument overrides json`,
19+
fs: () => projFs,
20+
scenario: "skipLibCheck",
21+
commandLineArgs: ["--b", "/src", "--skipLibCheck", "false", "--verbose"],
22+
});
23+
});
24+
}

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5246,6 +5246,7 @@ declare namespace ts {
52465246
verbose?: boolean;
52475247
incremental?: boolean;
52485248
assumeChangesOnlyAffectDirectDependencies?: boolean;
5249+
skipLibCheck?: boolean;
52495250
traceResolution?: boolean;
52505251
[option: string]: CompilerOptionsValue | undefined;
52515252
}

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5246,6 +5246,7 @@ declare namespace ts {
52465246
verbose?: boolean;
52475247
incremental?: boolean;
52485248
assumeChangesOnlyAffectDirectDependencies?: boolean;
5249+
skipLibCheck?: boolean;
52495250
traceResolution?: boolean;
52505251
[option: string]: CompilerOptionsValue | undefined;
52515252
}

tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

13+
/* Completeness */
14+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
15+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
16+
1317
/* Language and Environment */
1418
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
1519
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
@@ -73,7 +77,7 @@
7377
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
7478

7579
/* Type Checking */
76-
"strict": true, /* Enable all strict type-checking options. */
80+
"strict": true /* Enable all strict type-checking options. */
7781
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
7882
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
7983
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
@@ -92,9 +96,5 @@
9296
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
9397
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
9498
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
95-
96-
/* Completeness */
97-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
98-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
9999
}
100100
}

tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

13+
/* Completeness */
14+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
15+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
16+
1317
/* Language and Environment */
1418
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
1519
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
@@ -93,10 +97,6 @@
9397
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
9498
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
9599

96-
/* Completeness */
97-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
98-
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
99-
100100
/* Output Formatting */
101101
"noErrorTruncation": true /* Disable truncating types in error messages. */
102102
}

tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

13+
/* Completeness */
14+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
15+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
16+
1317
/* Language and Environment */
1418
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
1519
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
@@ -82,7 +86,7 @@
8286
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
8387
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
8488
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
85-
"noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
89+
"noUnusedLocals": true /* Enable error reporting when a local variables aren't read. */
8690
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
8791
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
8892
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
@@ -92,9 +96,5 @@
9296
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
9397
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
9498
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
95-
96-
/* Completeness */
97-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
98-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
9999
}
100100
}

tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

13+
/* Completeness */
14+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
15+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
16+
1317
/* Language and Environment */
1418
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
1519
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
@@ -73,7 +77,7 @@
7377
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
7478

7579
/* Type Checking */
76-
"strict": true, /* Enable all strict type-checking options. */
80+
"strict": true /* Enable all strict type-checking options. */
7781
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
7882
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
7983
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
@@ -92,9 +96,5 @@
9296
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
9397
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
9498
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
95-
96-
/* Completeness */
97-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
98-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
9999
}
100100
}

tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

13+
/* Completeness */
14+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
15+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
16+
1317
/* Language and Environment */
1418
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
1519
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
@@ -73,7 +77,7 @@
7377
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
7478

7579
/* Type Checking */
76-
"strict": true, /* Enable all strict type-checking options. */
80+
"strict": true /* Enable all strict type-checking options. */
7781
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
7882
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
7983
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
@@ -92,10 +96,6 @@
9296
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
9397
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
9498
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
95-
96-
/* Completeness */
97-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
98-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
9999
},
100100
"files": [
101101
"file0.st",

tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

13+
/* Completeness */
14+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
15+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
16+
1317
/* Language and Environment */
1418
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
1519
"lib": ["es5","es2015.promise"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
@@ -73,7 +77,7 @@
7377
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
7478

7579
/* Type Checking */
76-
"strict": true, /* Enable all strict type-checking options. */
80+
"strict": true /* Enable all strict type-checking options. */
7781
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
7882
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
7983
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
@@ -92,9 +96,5 @@
9296
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
9397
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
9498
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
95-
96-
/* Completeness */
97-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
98-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
9999
}
100100
}

tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

13+
/* Completeness */
14+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
15+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
16+
1317
/* Language and Environment */
1418
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
1519
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
@@ -73,7 +77,7 @@
7377
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
7478

7579
/* Type Checking */
76-
"strict": true, /* Enable all strict type-checking options. */
80+
"strict": true /* Enable all strict type-checking options. */
7781
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
7882
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
7983
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
@@ -92,9 +96,5 @@
9296
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
9397
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
9498
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
95-
96-
/* Completeness */
97-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
98-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
9999
}
100100
}

0 commit comments

Comments
 (0)