Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    TypeScript Up and Running in Seconds

    Robert PennerRobert Penner

    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
    typescriptTypeScript
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    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.

    Discuss

    Discuss