"skipLibCheck"
Skips error checking in .d.ts declaration files, which speeds up compilation.
Example
#{
"compilerOptions": {
"strict": true,
"skipLibCheck": true
}
}Definition and usage
#The skipLibCheck option turns off the search for errors inside all .d.ts declaration files: those in node_modules and your own. The compiler still reads types from them and checks your code against them, but it doesn’t verify the declarations themselves.
The main reasons to enable it are faster compilation and avoiding errors you have no control over, e.g. two @types packages declaring the same global variable, or library types written for another TypeScript version.
The price is less checking: a typo in your own .d.ts file goes unnoticed, and a type the compiler doesn’t recognize behaves like any. Even so, skipLibCheck: true is a very popular setting, present among others in the file created by tsc --init.
Syntax
#"skipLibCheck": trueMore examples
#// src/types/legacy.d.ts
declare function formatPrice(value: number): Strin
// Without skipLibCheck: Cannot find name 'Strin'. Did you mean 'String'?
// With skipLibCheck: no error
// src/app.ts
const label = formatPrice(49)
label.toFixedd(2)
// no error either, because the unknown type Strin acts like anyGood practices
#- In applications, leave
skipLibCheckon. If you write your own.d.tsfiles, check them from time to time by compiling without this option, e.g. in CI. - When errors in files from
node_modulesappear after updating packages,skipLibCheckwill hide them. Still, it’s worth checking that the project doesn’t have two different versions of the same@typespackage.
Related entries
#- declare and .d.ts filesDescribing the types of something that exists outside your TypeScript code: global variables, JavaScript libraries, and modules.
- "declaration"Generates .d.ts files with types next to the compiled JavaScript.
- "include" and "exclude"Which files the compiler takes into account, and which it skips.
- "strict"Turns on a set of the most important, rigorous compiler checks.
Spotted a mistake or missing an example? Write to us.