Leon Gaban
Leon Gaban

Reputation: 39044

TypeScript - error TS1146: Declaration expected

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?

Upvotes: 4

Views: 22042

Answers (2)

luhuang
luhuang

Reputation: 121

Try this

import { Component } from '@angular/core';

Upvotes: 4

kennypu
kennypu

Reputation: 6061

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

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

Upvotes: 3

Related Questions