4

I got the latest TypeScript via npm (npm install -g typescript)

Version 1.7.5

When I run the typescript compile command on my file: tsc app.component.ts --module system

I get the following error: app.component.ts(15,7): error TS1146: Declaration expected.

import {Component} from 'angular2/core';

    @Component({
        selector: 'my-app',
        // template: '<h1>My title: {{title}}</h1> <h2>Hardcoded h2</h2>'
    })
    @View({ // <- line 7
        templateUrl: '/templates/home.html',
        directives: []
    })
    .Class({
        constructor: function() {

        }
    }); // <- line 15

export class AppComponent {
    title = "My First Angular 2 App";
}

Anyone know what this error means?

2
  • 1
    i may be wrong, but don't you need to import View? line 1: import {Component, View} from 'angular2/core'; Commented Jan 12, 2016 at 4:23
  • 1
    You are right actually, I also found another answer saying I need to remove the ; at the end of my component. Now getting a different error error TS2307: Cannot find module 'angular2/core'. lol want to post your answer? This is what I updated the top line with import {Component, View, bootstrap} from 'angular2/core'; Commented Jan 12, 2016 at 4:25

2 Answers 2

4

Try this

import { Component } from '@angular/core';
Sign up to request clarification or add additional context in comments.

1 Comment

when downvoting please state why.. This answer is not valid because he is not using rc to begin with, he is still using beta or alpha, as you can see from import statement : 'angular2/core', which now has moved to the @angular namespace in rc. import { Component, View } from '@angular/core'; would be correct in newer versions.
3

you need to import View from angular2/core as well:

import {Component, View} from 'angular2/core';

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.