1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Setup a TypeScript Project

    John LindquistJohn Lindquist
    typescriptTypeScript
    ^3.2.1

    Getting started with TypeScript is easier than ever. You can setup a development environment right in your browser or even quickly put together a local environment in using the parcel bundler.

    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
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: The quickest way to try out TypeScript is to go to CodeSandbox.io. Go to create sandbox. Then scroll on down to vanilla plus TS for vanilla and TypeScript. You can access that directly at any time from /s for sandbox /vanilla/ts.

    Then from here, you already have a TypeScript file which you can play around with and edit to your heart's content. Hello TypeScript. Every change you make will automatically be reflected over here.

    Otherwise, with a local environment with Node installed, you can npm install/g parcelbundler. This will install parcel globally. Then with parcel installed, you can create a new file, call it index.html. I'll type a bang and hit tab to expand a default template. Then create a script tag with a source of ./index.ts. Then create a index.ts file, the one that's referenced there.

    Say console log hello from TypeScript. Then parcel can automatically handle everything for you. Just by typing parcel index.html, it will install TypeScript and start a server at port one, two, three, four, which I'll open up over here. Opening the console, you see hello from TypeScript.

    Lastly, I'm going to delete that folder. If you're a Node developer, you can say parcel, then target the TypeScript file, so index.ts. Then say --target equals Node. You'll see it compile to that dist folder again, this time with an index.js. You can run Node against that file. I can say Node dist/index.js. You'll see hello from TypeScript.