Automatically Compile Your TypeScript Files with Visual Studio Code on OSX
Join the DZone community and get the full member experience.Join For Free
some of my other articles about visual studio code :
- using typescript with visual studio code on osx
- setting up github with visual studio code on osx
- automatically compile your typescript files with visual studio code on osx
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 follow t his post and make sure typescript is installed and working.
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
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.
Published at DZone with permission of Michael Crump. See the original article here.
Opinions expressed by DZone contributors are their own.