Over a million developers have joined DZone.

Automatically Compile Your TypeScript Files with Visual Studio Code on OSX

· Performance Zone

Discover 50 of the latest mobile performance statistics with the Ultimate Guide to Digital Experience Monitoring, brought to you in partnership with Catchpoint.

Some of my other articles about Visual Studio Code :


I’ve been using Visual Studio Code since it was released at Build 2015. As I’ve been using this powerful editor, I’ve come across a couple of ways to make it even better and I thought I’d share it with the community. In this post, we are going to make our .ts (TypeScript) files auto-compile instead of performing the Build command every time we make changes to our .ts files.

Before we get started, simply followt his post and make sure TypeScript is installed and working.

Split-Screen FTW

We are going to use the split-screen functionality of Visual Studio Code in order to see both of our TypeScript and generated JavaScript file. Simply press the button highlighted below or press CMD-\ :


Put your TypeScript file that you are currently working on in the left panel and the generated JavaScript file in the right panel. Notice that if you make a change to the TypeScript file, the JavaScript file is not updating. You will need to press the CMD-Shift-B in order to compile the file. EVERY. SINGLE. TIME.


A Little Help from TSC

Navigate to your Visual Studio Code Folder and open a terminal window here and enter the following command:

tsc *.ts --watch

This is going to monitor the folder for any changes in our TypeScript files and compile them behind the scenes. Here is what the output looks like once you start it:

message TS6042: Compilation complete. Watching for file changes.
message TS6032: File change detected. Starting incremental compilation...
message TS6042: Compilation complete. Watching for file changes.

Switch Back to Visual Studio Code

If you were already in the split-screen mode, then you should have noticed the change in your JavaScript file already. As you begin typing, it will automatically compile your TypeScript file as shown below.


Note: Since this is a Node app, Control-C will kill the process in the terminal window if you want to stop tsc from watching for file changes.

Like this Post?

Thanks for reading and if you like this post, then share it with one of the buttons below. Also, feel free to leave a comment below.

Is your APM strategy broken? This ebook explores the latest in Gartner research to help you learn how to close the end-user experience gap in APM, brought to you in partnership with Catchpoint.


Published at DZone with permission of Michael Crump. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}