paint-brush
How To Set Up a tsconfig For Nodejsby@theBenForce
1,341 reads
1,341 reads

How To Set Up a tsconfig For Nodejs

by Ben ForceApril 26th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Microsoft has created a collection of platform-specific presets to base your tsconfig on. The preset is installed as an. npm package and referenced using the extends property in your. tsconfig. The power behind the. extends property is that you can easily get started on a project with optimized settings. If you have multiple TypeScript projects you can. create your own tsconfig preset. Previously published at https://justwriteapps.com/using-tsconfig-presets/ Previously published by Ben Force.

Company Mentioned

Mention Thumbnail
featured image - How To Set Up a tsconfig For Nodejs
Ben Force HackerNoon profile picture

Do you hate dealing with tsconfig files? My problem is that I just don't spend enough time with them to learn all the settings. I create the config once for a new project, usually leaving most things as default, then never touch it again.

Fortunately, I recently discovered that Microsoft has created a collection of platform-specific presets to base your tsconfig on. The preset is installed as an npm package and referenced using the extends property in your tsconfig.

To setup a typescript project for node 14 install the @tsconfig/node14 preset.

npm install --save-dev @tsconfig/node14

Now your tsconfig can be as simple as one property, but any settings in your tsconfig will override the preset values.

{
  "extends": "@tsconfig/node14/tsconfig.json"
}

The power behind the extends property is that you can easily get started on a project with optimized settings, and if you have multiple TypeScript projects you can create your own tsconfig preset!

References

Previously published at https://justwriteapps.com/using-tsconfig-presets/