DEV Community

Discussion on: Setting up a GatsbyJS starter with TypeScript, ESLint, Prettier and pre-commit hooks

Collapse
 
antoinerousseau profile image
Antoine Rousseau • Edited

Thanks for the post!
I was able to use TypeScript in my Gatsby project without the need of a tsconfig.json, is it really necessary and why?
Also, you can even write your Gatsby Node files in TypeScript too: github.com/gatsbyjs/gatsby/issues/...

Collapse
 
nickytonline profile image
Nick Taylor • Edited

You want the tsconfig.json so that you can configure tsc when you run it as just a type checker. At a minimum, you want the compiler option "noEmit" set to true, so it doesn't generate JS files (the default behaviour). We want Babel to do that. Also, for example, in my tsconfig.json, I have it configured for strict mode, github.com/nickytonline/iamdevelop....

Collapse
 
ardennl profile image
Arden de Raaij • Edited

Hi Antoine, thanks for the reply and kind words!

As far as I experienced, I did need a tsconfig.json in the root of my project, even if it only contained {}. But this was only to run the tsc command from an NPM script or the command line. If you are not using any type checking through the command line or NPM scripts, you can still benefit from type checking in your editor if it supports it. I guess in that case, you wouldn't explicitly need a tsconfig.json.