TypeScript Setup & Install
To start using TypeScript, you need Node.js and npm installed on your machine. Once you have those, you can install the TypeScript compiler globally or as a project dependency using npm.
After installing, the `tsc` command becomes available, which compiles .ts files into .js files. Most real projects install TypeScript locally per project so that everyone on the team uses the same version.
npm install -g typescript
tsc --versionInstalling TypeScript
Run `npm install -g typescript` to install it globally, or `npm install --save-dev typescript` to add it to a single project. Global installs are handy for quick experiments.
Checking the version
After installation, run `tsc --version` to confirm TypeScript is installed correctly and see which version you have.
npm install -g typescriptadded 1 packageInstalls the TypeScript compiler globally so `tsc` works from any folder.
tsc --versionVersion 5.4.5Confirms that TypeScript was installed successfully.
Key points
- TypeScript requires Node.js and npm to install.
- `npm install -g typescript` installs it globally.
- `npm install --save-dev typescript` installs it just for one project.
- `tsc --version` checks the installed compiler version.
