Getting Started with TypeScript & Angular

Install TypeScript and TypeScript Definition Manager

(obviously you’ll need nodejs installed first)

npm install typescript -g
npm install tsd -g

Assume you have a file named ‘myTypeScriptModule.ts’ with the following code:


To transpile the TypeScript to JavaScript, simply run this command:

tsc myTypeScriptModule.ts

You will now get an error that TypeScript could not find symbol “angular”.

This is where the TypeScript Definition manager comes into play.

In your typescript directory, create a new typescript project by running:

tsd init

Then install the definition file for angular:

tsd query angular --action install

This will download and create a new directory containing your angular definition file. Include it by updating your typescript file to point to the angular definition:

/// <reference path="angularjs/angular.d.ts" />

Try to transpile again, and it should generate the JS file without error:

tsc myTypeScriptModule.ts

They have a lot of other types as well:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s