TypeScript Up and Running in Seconds

Robert Penner
InstructorRobert Penner
Share this video with your friends

Social Share Links

Send Tweet
Published 10 years ago
Updated 6 years ago

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

[00:00] 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.

[00:17] 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.

[00:32] 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.

Robert Penner
Robert Pennerinstructor
~ 10 years ago

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".

Markdown supported.
Become a member to join the discussionEnroll Today