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/...
I'm a fan of Open Source and have a growing interest in serverless and edge computing. I'm not a big fan of spiders, but they're doing good work eating bugs. I also stream on Twitch.
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....
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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/...
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 totrue
, 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....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 thetsc
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 atsconfig.json
.