![](/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.