DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • Which Is Better for IoT: Azure RTOS or FreeRTOS?
  • An Overview of Kubernetes Security Projects at KubeCon Europe 2023
  • Never Use Credentials in a CI/CD Pipeline Again
  • 4 Expert Tips for High Availability and Disaster Recovery of Your Cloud Deployment

Trending

  • Which Is Better for IoT: Azure RTOS or FreeRTOS?
  • An Overview of Kubernetes Security Projects at KubeCon Europe 2023
  • Never Use Credentials in a CI/CD Pipeline Again
  • 4 Expert Tips for High Availability and Disaster Recovery of Your Cloud Deployment
  1. DZone
  2. Coding
  3. JavaScript
  4. Automatically Compile Your TypeScript Files with Visual Studio Code on OSX

Automatically Compile Your TypeScript Files with Visual Studio Code on OSX

Michael Crump user avatar by
Michael Crump
·
Jun. 03, 15 · Interview
Like (0)
Save
Tweet
Share
5.61K Views

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

introduction

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.

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-\ :

image

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.

image

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.

image

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.


Visual Studio Code code style TypeScript

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

Opinions expressed by DZone contributors are their own.

Trending

  • Which Is Better for IoT: Azure RTOS or FreeRTOS?
  • An Overview of Kubernetes Security Projects at KubeCon Europe 2023
  • Never Use Credentials in a CI/CD Pipeline Again
  • 4 Expert Tips for High Availability and Disaster Recovery of Your Cloud Deployment

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: