Leon Gaban Leon Gaban - 5 months ago 308x
Javascript Question

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';

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

}); // <- line 15

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

Anyone know what this error means?


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

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