To install and configure TypeScript in your project, you need to perform the following steps:
npm init
npm install --save-dev typescript
tsconfig.json
file in your project directory to specify the compiler options for building your project. For example:{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"outDir": "./dist",
"rootDir": "./src"
},
"exclude": ["node_modules"]
}
tsc
Note: You can also compile individual TypeScript files by specifying the file name after the tsc command. For example:
tsc index.ts
And you’re all set! You can now start writing TypeScript code in your project.
Learn more from the following links: