Skip to content

Commit

Permalink
Implement --skipLibCheck flag in tsbuild
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MarcCelani-at committed Sep 2, 2021
1 parent 5daa6f4 commit f250955
Show file tree
Hide file tree
Showing 25 changed files with 372 additions and 93 deletions.
14 changes: 7 additions & 7 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ namespace ts {
description: Diagnostics.Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit,
defaultValueDescription: Diagnostics.Platform_specific
},
{
name: "skipLibCheck",
type: "boolean",
category: Diagnostics.Completeness,
description: Diagnostics.Skip_type_checking_all_d_ts_files,
defaultValueDescription: "false"
},
];

/* @internal */
Expand Down Expand Up @@ -1094,13 +1101,6 @@ namespace ts {
description: Diagnostics.Specify_the_output_directory_for_generated_declaration_files,
defaultValueDescription: "n/a"
},
{
name: "skipLibCheck",
type: "boolean",
category: Diagnostics.Completeness,
description: Diagnostics.Skip_type_checking_all_d_ts_files,
defaultValueDescription: "false"
},
{
name: "allowUnusedLabels",
type: "boolean",
Expand Down
1 change: 1 addition & 0 deletions src/compiler/tsbuildPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace ts {
/*@internal*/ pretty?: boolean;
incremental?: boolean;
assumeChangesOnlyAffectDirectDependencies?: boolean;
skipLibCheck?: boolean;

traceResolution?: boolean;
/* @internal */ diagnostics?: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/testRunner/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
"unittests/tsbuild/referencesWithRootDirInParent.ts",
"unittests/tsbuild/resolveJsonModule.ts",
"unittests/tsbuild/sample.ts",
"unittests/tsbuild/skipLibCheck.ts",
"unittests/tsbuild/transitiveReferences.ts",
"unittests/tsbuildWatch/configFileErrors.ts",
"unittests/tsbuildWatch/demo.ts",
Expand Down
24 changes: 24 additions & 0 deletions src/testRunner/unittests/tsbuild/skipLibCheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace ts {
describe("unittests:: tsbuild:: on project with skipLibCheck set to true", () => {
let projFs: vfs.FileSystem;
before(() => {
projFs = loadProjectFromDisk("tests/projects/skipLibCheck");
});
after(() => {
projFs = undefined!;
});

verifyTsc({
subScenario: `program options include skipLibCheck`,
fs: () => projFs,
scenario: "skipLibCheck",
commandLineArgs: ["--b", "/src", "--verbose"],
});
verifyTsc({
subScenario: `command line argument overrides json`,
fs: () => projFs,
scenario: "skipLibCheck",
commandLineArgs: ["--b", "/src", "--skipLibCheck", "false", "--verbose"],
});
});
}
1 change: 1 addition & 0 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5246,6 +5246,7 @@ declare namespace ts {
verbose?: boolean;
incremental?: boolean;
assumeChangesOnlyAffectDirectDependencies?: boolean;
skipLibCheck?: boolean;
traceResolution?: boolean;
[option: string]: CompilerOptionsValue | undefined;
}
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5246,6 +5246,7 @@ declare namespace ts {
verbose?: boolean;
incremental?: boolean;
assumeChangesOnlyAffectDirectDependencies?: boolean;
skipLibCheck?: boolean;
traceResolution?: boolean;
[option: string]: CompilerOptionsValue | undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Completeness */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */

/* Language and Environment */
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
Expand Down Expand Up @@ -73,7 +77,7 @@
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -92,9 +96,5 @@
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Completeness */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */

/* Language and Environment */
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
Expand Down Expand Up @@ -93,10 +97,6 @@
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */

/* Output Formatting */
"noErrorTruncation": true /* Disable truncating types in error messages. */
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Completeness */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */

/* Language and Environment */
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
Expand Down Expand Up @@ -82,7 +86,7 @@
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
"noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
"noUnusedLocals": true /* Enable error reporting when a local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
Expand All @@ -92,9 +96,5 @@
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Completeness */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */

/* Language and Environment */
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
Expand Down Expand Up @@ -73,7 +77,7 @@
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -92,9 +96,5 @@
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Completeness */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */

/* Language and Environment */
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
Expand Down Expand Up @@ -73,7 +77,7 @@
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -92,10 +96,6 @@
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"files": [
"file0.st",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Completeness */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */

/* Language and Environment */
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["es5","es2015.promise"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
Expand Down Expand Up @@ -73,7 +77,7 @@
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -92,9 +96,5 @@
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Completeness */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */

/* Language and Environment */
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
Expand Down Expand Up @@ -73,7 +77,7 @@
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -92,9 +96,5 @@
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

0 comments on commit f250955

Please sign in to comment.