"skipLibCheck"

Skips error checking in .d.ts declaration files, which speeds up compilation.

On this page

Example

#
JSON
{
  "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

#
Syntax
"skipLibCheck": true

More examples

#
An error in your own declaration
TypeScript
// 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 any

Good practices

#
  • In applications, leave skipLibCheck on. If you write your own .d.ts files, check them from time to time by compiling without this option, e.g. in CI.
  • When errors in files from node_modules appear after updating packages, skipLibCheck will hide them. Still, it’s worth checking that the project doesn’t have two different versions of the same @types package.

Related entries

#

Spotted a mistake or missing an example? Write to us.