How To Disable Type Checking For node_modules In TypeScript

Disable type checking for node_modules in TypeScript

This article will show you how to disable type checking for node_modules in TypeScript. We provide you with two approaches: use the ‘skipLibCheck‘ flag or Setting the skipLibCheck property. Let’s go into detail.

Disable type checking for node_modules in TypeScript

The method that I want to mention here is to use the ‘skipLibCheck‘. 

With the skipLibCheck option, the TypeScript compiler will be forced to skip the type checking for all declaration files (.d.ts). Include your custom ‘*.d.ts‘ files as well as ‘*.d.ts‘ files from the node_modules directory.

Using the skipLibCheck option saves compile time by ignoring the type checking of a large number of declarations in the dependencies. 

To help you understand the idea of ​​using the skipLibCheck, I will explain the following small example:

In demo.d.ts:

type Student = Person   //Invalid syntax

Suppose you define the type Student with the type Person even though ‘Person‘ does not exist. Usually, without using ‘skipLibCheck’, the program will crash, and you will not be able to compile your program. However, with ‘skipLibCheck’, the error will be ignored and treated as if nothing happened.

You can implement this method in two ways:

Using the –skipLibCheck flag

The first approach I want to show you is to use the –skipLibCheck flag when executing this command in the command line. 

tsc --skipLibCheck

This method is the first way you should think about because it’s quick and straightforward.

Setting the skipLibCheck property to true

Another option for you:

  • Open the tsconfig.json file
  • Look for the ‘compilerOptions‘ object
  • Set the value of the property ‘skipLibCheck‘ to ‘true

After editing, your tsconfig.json might look like this:

  "compilerOptions": {
    "skipLibCheck": true,

In case the error is still not fixed, check the exclude array in tsconfig.json to see if there is a path to the node_modules directory.

For instance:

  "compilerOptions": {
    "skipLibCheck": true,
  "exclude": ["node_modules"]

There are a few things that need clarification:

  1. Even though you disable type check, TypeScript will still type check the code in your program. However, instead of performing the test on all ‘*.d.ts‘ files, it will only check the specific pieces of code that you refer to in your application.
  2. When using the skipLibCheck option, it does not mean that declaration files are entirely ignored. TypeScript compiler will just ignore errors from these files.

Note: Also, pay attention to the TypeScript version you are using. With some older versions, the ‘skipLibCheck‘ option will not work. So if you are using an old version of TypeScript, update to a newer version if you want to use the ‘skipLibCheck‘ option.


So, that’s all I want to cover in this post. The above two approaches give the same results. You can try either way to disable type checking for node_modules in TypeScript. Good luck for you!

Maybe you are interested:

Leave a Reply

Your email address will not be published. Required fields are marked *