⚠️ This lesson is retired and might contain outdated information.

Installing TypeScript and Running the TypeScript Compiler (tsc)

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 8 years ago
Updated 5 years ago

This lesson shows you how to install TypeScript and run the TypeScript compiler against a .ts file from the command line.

[00:00] To install the TypeScript compiler, you use npm, and type npm install -g typescript. That will download and install the compiler. Once that's done, you can test it with tsc -v, so TypeScript compiler version, and will print the version number.

[00:17] Now, I have the compiler installed. I'll create a new file, call it app.ts. I'll try to class it and call it Person. Save that, and come over here and say tsc app.ts. This will compile our app TypeScript file for us. You can see the output here is app.js. It converted what we have as a class defined here to what a class would be defined as in ES5.

[00:47] If you want to output to a different file, you do --out and say something like bundle.js, and then pass in the file you want to compile. I'll hit Enter. You'll see now we get a bundle, which has the same output as our app.js had before.

[01:04] Lastly, if you want to continuously watch with -w, or --watch, then you can watch, give it an Out-File of bundle.js, pass in your file of app.ts. Once I hit Enter, you can see that it's watching for file changes. If I come over here, and I add name equals John, I hit Save, you can see it triggered a File Change Detected.

[01:31] If I check my bundle, you'll see it added this as John. Let's split these, and make this full size so we can see this in action. I'll change this to Sally. Hit save. You can see it automatically updates my file over here.

[01:48] The TypeScript compiler has many, many more options, which you can find under Help. You probably won't use them in the command line. You'll probably use a configuration file to define all of these.

bachofner
bachofner
~ 7 years ago

Hi, thanks for the course, it is really what I needed. May I ask which theme are you using for vsc? :)

Stephan Maier-Knodt
Stephan Maier-Knodt
~ 7 years ago

Hi, will you update all the TS courses to version 2.3? If yes, when? Kind regards, Stephan

Antonio Gil
Antonio Gil
~ 6 years ago

Please update to the latest Typescript version, thanks!

Mateo
Mateo
~ 6 years ago

Any chance we can get value out of this course by getting it upgrade it to 2.6 ?

Jonathan
Jonathan
~ 5 years ago

why is this coursed flagged as retired?

Mateo
Mateo
~ 5 years ago

Because everyone is using ReasonML instead... :)

Dan
Dan
~ 5 years ago

It would be really helpful if they gave a bit more reason behind this. As someone who want's to get started with Typescript this seems like the most logical place to start, but now I'm 🤷‍♂️

Markdown supported.
Become a member to join the discussionEnroll Today