TypeScript skipLibCheck still checking node_modules libs

skipLibCheck is not meant to prevent all type checking in node_modules. Although it may work for some projects, but it’s just a coincidence. You could say it works partially, true. Here’s what it does:

Skip Lib Check – skipLibCheck

Skip type checking of declaration files.

This can save time during compilation at the expense of type-system
accuracy. For example, two libraries could define two copies of the
same type in an inconsistent way. Rather than doing a full check of
all d.ts files, TypeScript will type check the code you specifically
refer to in your app’s source code
.

A common case where you might think to use skipLibCheck is when there
are two copies of a library’s types in your node_modules. In these
cases, you should consider using a feature like yarn’s resolutions to
ensure there is only one copy of that dependency in your tree or
investigate how to ensure there is only one copy by understanding the
dependency resolution to fix the issue without additional tooling.

skipLibCheck was introduced in Typescipt 2.0, so upgrading Typescript isn’t really a fix. Yet again it may work for some people.
Now I had a case when I had to add a library using Typescript 4 to a project using Typescript 3. It was raining errors on build. Having the same version of typescript helped. The version of typescript would be specific to your project here.

The only quick solution I know is to use require instead of import (my project was backend):

import * as lib from 'lib';
const lib = require('lib');

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)