Author : MD TAREQ HASSAN
Installing TypeScript
Download & install Node.js: https://nodejs.org/en/download/
Install TypeScript
npm install -g typescript
Compile TypeScript
tsc foo.ts
Output: foo.js
TypeScript in Visual Studio
MSBuild Nuget package
If you add new .ts
file to your project, them Visual Studio might ask to install following
Install-Package Microsoft.TypeScript.MSBuild
TypeScript support
- Visual studio has support for TypeScript by default
- The TypeScript SDK, available by default in the Visual Studio installer
- Visual Studio provides rich support for JavaScript development, both using JavaScript directly, and also using the TypeScript
- NuGet package: when the NuGet package for TypeScript 3.2 or higher is installed into your project, the corresponding version of the TypeScript language service gets loaded in the editor
- npm package: when the npm package for TypeScript 2.1 or higher is installed into your project, the corresponding version of the TypeScript language service gets loaded in the editor
- Links:
On compilation (every time), Visual Studio will create .js
file from .ts
file (expand Foo.ts
=> Foo.js
)
Installing Node.js Workloads
- Menu > Tools > Get Tools & Features
- Workloads > Node.js development
Config file
- Open CMD/PowerShell/Git Bash
- Go to project folder (
cd <projectFolder
>) > Command:tsc --init
tsconfig.json
will be created- In Visual Studio: Right Click > Add > TypeScript Config File