Benjamin Read's code garden.

How to scope Typecheck to your project folder

Published on

This article is about: javascripttypescript

Published on Tuesday, 31 March 2020

I configured a command so that I can run a type check on my project, but the results always include stuff in the node_modules folder. It took me a lot of investigation and asking around before I figured out how to scope tsc to only the ./src/ folder?

in package.json:

"scripts: {
  "typecheck": "tsc --noEmit"

With this configuration, he compiler should pick up config from tsconfig.json, which looks like this:

  "compilerOptions": {
  "include": ["src/**/*"],
  "exclude": ["node_modules", "**/*.test.*"]

But I still get results from node_modules when I run the command. It took me ages to figure it out, but for anyone else coming across this one, I managed to find that submitting an empty array to types did it:

"compilerOptions": {
    "types": []

Read more articles about: javascripttypescript


No comments yet. Be the first to comment!

“Wisest are they who know they do not know.”

— Jostein Gaarder