![](/img/trans.png)
[英]Getting: error TS1128: Declaration or statement expected. In ReactJS & TypeScript app
[英]TypeScript - error TS1146: Declaration expected
我通过 npm ( npm install -g typescript
) 获得了最新的TypeScript
Version 1.7.5
当我在我的文件上运行打字稿编译命令时: tsc app.component.ts --module system
我收到以下错误: 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";
}
有人知道这个错误是什么意思吗?
试试这个
import { Component } from '@angular/core';
您还需要从angular2/core
导入View
:
import {Component, View} from 'angular2/core';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.