Member-only story

Introduction to Typescript — Part 2 : Creating ts config file.

Praveen David Mathew
2 min readNov 3, 2021

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 :

  1. 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:

  1. Create a new folder and then run:
tsc --init

2. Enable error for unused variable

--

--

Praveen David Mathew
Praveen David Mathew

Written by Praveen David Mathew

An open source advocator/WebdriverIO Projectcommiter/Postman Supernova/Postman-html-extra contributor/Stack overflow sqa moderator/Speaker

No responses yet