If you're using Visual Studio 2017, TypeScript comes pre-installed with Update 2, which includes the latest version 2.3 and allows for side by side installations. If you don't have it, you can easily add it through the Visual Studio Installer - simply click on the burger menu, select Modify, then go to Individual Components and choose TypeScript under SDKs, Libraries, and Frameworks.
After installation, you can configure TypeScript's behavior by creating a tsconfig.json file. Here's an example:
{
"compileOnSave": true,
"compilerOptions":
{
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"exclude":
[
"node_modules"
]
}
The key setting here is compileOnSave, which triggers compilation of the JavaScript file when saving the TypeScript file in Visual Studio.
Once set up, you'll notice a nested JavaScript file within your TypeScript file like this:
https://i.sstatic.net/wCtch.png
To see changes in real-time, open both files side by side and enable automatic updating (you may need to tick the always update option if prompted by VS). Now, whenever you save the TypeScript file, the corresponding JavaScript file will update automatically.