Member-only story
Introduction to Typescript — Part 2 : Creating ts config file.
We have seen what is typescript , why we use it and so on , in our previous blog. There we mentioned that typescript is a superset of javascript and adds more compiler and syntax rules that helps us to do static type and error checking, which helps in writing better error free code.
https://praveendavidmathew.medium.com/introduction-to-typescript-world-part-1-8f8075f6d310
Typescript compiler allows you to customize these rules in two ways :
- by passing commandline argument to the compiler, an example would be :
tsc ./index.ts --strict
2. Or using the tsconfig.json
the command line argument doesn’t support all the flags, instead you can use tsconfig file in the root of the project and define all the required rules
you can create a tsconfig.json as
tsc --init
now your favorite IDE will pickup the rules while doing static code analysis on the code and tsc uses it during compilation
Lets Check tsconfig behavior:
- Create a new folder and then run:
tsc --init
2. Enable error for unused variable