DEV Community

Erik Guzman
Erik Guzman

Posted on • Edited on

5 2

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.

Postgres on Neon - Get the Free Plan

No credit card required. The database you love, on a serverless platform designed to help you build faster.

Get Postgres on Neon

Top comments (1)

Collapse
 
juancarlospaco profile image
Juan Carlos

Nice, that should be the default maybe.

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay