javascript - TypeScript - error TS1146: Se esperaba una declaración
Obtuve el último TypeScript a través de npm (npm install -g typescript)
Version 1.7.5Cuando ejecuto el comando de compilación de TypeScript en mi archivo: tsc app.component.ts --module system
Recibo el siguiente error: app.component.ts(15,7): error TS1146: Se esperaba una declaración.
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";
}
¿Alguien sabe qué significa este error?
Respuesta #1
Intenta esto
import { Component } from '@angular/core';
Respuesta #2
también necesitas importar View desde angular2/core:
import {Component, View} from 'angular2/core';