Enter Your Email Address to Watch This Lesson

Your link to unlock this lesson will be sent to this email address.

Unlock this lesson and all 986 of the free egghead.io lessons, plus get TypeScript content delivered directly to your inbox!



Existing egghead members will not see this. Sign in.

TypeScript Up and Running in Seconds

0:51 TypeScript lesson by

It’s easy to get up and running with TypeScript, a strongly-typed superset of JavaScript. We’ll cover:
- installing the compiler with Node.js
- compiling TypeScript to JavaScript
- auto-watching source files for changes
- fixing code errors found by TypeScript

Get the Code Now
click to level up

egghead.io comment guidelines

Avatar
egghead.io

It’s easy to get up and running with TypeScript, a strongly-typed superset of JavaScript. We’ll cover:
- installing the compiler with Node.js
- compiling TypeScript to JavaScript
- auto-watching source files for changes
- fixing code errors found by TypeScript

Avatar
Robert

For this video, I used Sublime Text 3 without any TypeScript package installed. However, I recommend trying Microsoft's TypeScript package. It's in alpha state, but has excellent code completion, safe renaming, go to declaration and find references.

https://github.com/Microsoft/TypeScript-Sublime-Plugin

It can be installed via the popular Package Control in Sublime. Look for the package named simply "TypeScript".

We can have a TypeScript workflow up and running in seconds, using only Node and a text editor. First, we'll install the TypeScript compiler globally with Node's package manager. Let's create a simple TypeScript file and pass it to tsc, the TypeScript compiler.

This generates a JavaScript file, which we can run in Node and see that it's working. Let's view our ts and js files side by side. We can ask the TypeScript compiler to watch all ts files for changes.

Now, when we edit the TypeScript file, it's compiled to JavaScript automatically on save. If our TypeScript is incorrect, the compiler shows an error message with the line number. We are missing a new in line two. Let's fix it. Save. We're good to go.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?