diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 422e08eccd5f6..0d3b1ad3c0f96 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -16383,14 +16383,11 @@ namespace ts {
function checkSourceFileWorker(node: SourceFile) {
const links = getNodeLinks(node);
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 (compilerOptions.skipDefaultLibCheck) {
- // If the user specified '--noLib' and a file has a '/// ',
- // then we should treat that file as a default lib.
- if (node.hasNoDefaultLib) {
- return;
- }
+ // If skipLibCheck is enabled, skip type checking if file is a declaration file.
+ // If skipDefaultLibCheck is enabled, skip type checking if file contains a
+ // '/// ' directive.
+ if (compilerOptions.skipLibCheck && node.isDeclarationFile || compilerOptions.skipDefaultLibCheck && node.hasNoDefaultLib) {
+ return;
}
// Grammar checking
diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts
index a8d955d3b16fb..80d7f0b1f161f 100644
--- a/src/compiler/commandLineParser.ts
+++ b/src/compiler/commandLineParser.ts
@@ -139,6 +139,11 @@ namespace ts {
name: "skipDefaultLibCheck",
type: "boolean",
},
+ {
+ name: "skipLibCheck",
+ type: "boolean",
+ description: Diagnostics.Skip_type_checking_of_declaration_files,
+ },
{
name: "out",
type: "string",
diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json
index 6e892c46dca95..9942a71df3bba 100644
--- a/src/compiler/diagnosticMessages.json
+++ b/src/compiler/diagnosticMessages.json
@@ -2348,6 +2348,10 @@
"category": "Message",
"code": 6011
},
+ "Skip type checking of declaration files.": {
+ "category": "Message",
+ "code": 6012
+ },
"Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'": {
"category": "Message",
"code": 6015
diff --git a/src/compiler/types.ts b/src/compiler/types.ts
index 15fd2bd4fcff1..689812ed4194e 100644
--- a/src/compiler/types.ts
+++ b/src/compiler/types.ts
@@ -2505,6 +2505,7 @@ namespace ts {
allowJs?: boolean;
noImplicitUseStrict?: boolean;
strictNullChecks?: boolean;
+ skipLibCheck?: boolean;
listEmittedFiles?: boolean;
lib?: string[];
/* @internal */ stripInternal?: boolean;