i) Check what version of node you are running. $ node -V
ii) Install typescript globally in your machine $ npm install -g typecript
iii) Install tsconfig node module for the node version that you are running in your local machine $ npm install --save-dev @tsconfig/node14
iv) In the folder that you have created for testing TypeScript, create tsconfig.json file with the following parameters { "$schema": "https://json.schemastore.org/tsconfig", "display": "Node 14", "compilerOptions": { "lib": ["es2020", "dom"], "module": "commonjs", "target": "es2020", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true } , "extends": "@tsconfig/node14/tsconfig.json" }
v) To compile typescript to js, you will use a command similar to $ tsc mytypescriptprogram.ts
Note: If tsconfig.json file is not there, then the code editor will throw errors such as duplicate class found in the code.