DEV Community

Erik Guzman
Erik Guzman

Posted on • Updated on

TIL: Tell TypeScript not to type check node_modules

I am currently working on an Express.js + GraphQL + TypeScript side project for fun. Local development has been great so far, and I have been using ts-node while developing locally.

All my types check out, and everything is looking good, time to build for production! I run npm run build, and BAM I got hit with an error!

This is the error I am seeing:

> npm -s run clean && tsc

node_modules/apollo-server-express/node_modules/@types/express/index.d.ts:110:54 - error TS2315: Type 'Response' is not generic.

110     export interface Response<ResBody = any> extends core.Response<ResBody> { }
                                                         ~~~~~~~~~~~~~~~~~~~~~~


Found 1 error.

What the Heck! I am getting a type error way down in the guts of the node_module dependencies that have nothing to do with my code.

After spending way to much time searching around trying to figure out a fix. It turns out it was under my nose the WHOLE TIME. Just a simple flag to pass to the tsc CLI tool, --skipLibCheck

I just had to update my build command in my package.json and it all builds just fine

npm -s run clean && tsc --skipLibCheck

I hope this saves you some time if your a novice TypeScript developer like myself.

Top comments (1)

Collapse
 
juancarlospaco profile image
Juan Carlos

Nice, that should be the default maybe.