DEV Community

So, your friends hate Typescript. Using Typescript without using Typescript.

M. Andrew Darts on January 28, 2020

It's fine. You like to know what is going on in your codebase. Your friends, on the other hand, are more like cowboys. Enough trying to convince th...
Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

Thanks. This might come in handy when I want to run node ./script.js, but I want to skip the compilation step for TypeScript, nor do I want to rely on ts-node.

For example, when I want to create a CLI script ("bin" field in package.json).

Furthermore, as I use Node 10, I cannot use import as well, only require, but this shouldn't be a problem, is it?

Collapse
 
mandrewdarts profile image
M. Andrew Darts • Edited

Definitely, that would be a good use case!

Using require shouldn't be a problem.

I love using this approach when I want to avoid a build step altogether.

I really appreciate you taking the time to check this out.

Collapse
 
michaeljota profile image
Michael De Abreu

Great article. BTW, jsconfig.json files are just tsconfig.json files with checkJs: true by default, so there is no need for that. :P.

Collapse
 
mandrewdarts profile image
M. Andrew Darts

Didn't know that, Pro tip!
Thanks 🤘

Collapse
 
hersman profile image
Hersh

Good article. I noticed a small grammatical error. "Now we can use the Typescript compiler will parse our .js files." should be "Now we can use the Typescript compiler to parse our .js files.".

Collapse
 
mandrewdarts profile image
M. Andrew Darts

Thanks! Updating now 🤘

Collapse
 
vovchisko profile image
Vladimir Ishenko

Meanwhile in real world JSDoc only missing mapped types. And for good, I guess ;)