Set TS version for VSCode intellisence
VS Code command palette: > TypeScript: Select TypeScript version
Format TypeScript Document
This will format the entire document.
Shift + Alt + FShift + Option + FFormat Selection
Ctrl + K Ctrl + FCmd + K Cmd + FDuplicate code line
Alt + Shift + Down Arrow or Alt + Shift + Up Arrow
Check TypeScript versions: npm list typescript
1. Install Node.js
2. Install TypeScript
npm install -g typescript3. Initialize Your Project
npm init -y4. Create a TypeScript Configuration File
tsc --initThis file enables you to specify various compiler options such as the target JavaScript version, the module system, source maps, the output directory, etc.
5. Create a .ts file in your project
For example,
hello.ts.6. Compile TypeScript
tsc hello.ts7. Automate the Compilation Process
To make the process easier, you can configure VS Code to build your TypeScript files automatically:
Ctrl + Shift + P.Tasks: Configure Default Build Taskand press Enter.tsc: build - tsconfig.jsonfrom the list. This creates atasks.jsonfile in the.vscodefolder.Now, you can build your TypeScript project by pressing
Ctrl + Shift + Bor running the build task through the Terminal menu.8. Watch Mode
To automatically compile your TypeScript files whenever you save them, you can start the TypeScript compiler in watch mode. In the terminal, run:
tsc --watchThis command will monitor your TypeScript files for changes and recompile them automatically.