0

I am just trialling AngularJS 2.0 with the poor mans reddit. I have the following script which is called app.ts

///<reference path="typings/angular2/angular2.d.ts" />

import {
    Component,
    View,
    bootstrap,
} from "angular2/angular2";

@Component({
    selector: 'hello world'
})
@View(
    { template: `<div>HelloWorld</div>` })
class HelloWorld {
}
bootstrap(HelloWorld)

However, after saving this, I'd like to compile it into javascript (js file) Using tsc app.ts I think should work, but the compiler spits out a number of errors to the command line.

I have installed the tsc via npm install -g 'typescript@^1.5.0-beta' and ran npm install. The errors I get are along the lines of:

C:\angular2-reddit\typings\angular2\angular2.d.ts(7,22): error TS1005: ')' expec
ted.
C:\angular2-reddit\typings\angular2\angular2.d.ts(14,6): error TS1008: Unexpecte
d token; 'module, class, interface, enum, import or statement' expected.

Can anyone shed any light on what I am doing wrong here?

Thanks...

1 Answer 1

1

You need to provide a couple of parameters to the compiler for it to work.

> tsc.cmd -m commonjs -t es5 --emitDecoratorMetadata app.ts

Also make sure you have the proper typescript definition files from the definitelytyped repo.

> npm install -g tsd@^0.6.0
> tsd install angular2 es6-promise rx rx-lite
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.