带有TypeScript的Angular2:在@component之后声明预期的编译器错误

Angular2 with TypeScript: Declaration expected compiler error after @component

尽管我从 angular2/core 导入了组件,但我还是收到了这种错误,它的来源应该是文件不是通过 npm 安装下载的,或者我的节点需要升级

这是我的文件

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

@Component({

})

在组件后面定义一个 class。

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

@Component({

})
class MyClass {

}

@Component 只是一个包含 class 元数据的装饰器。换句话说,它只是以更优雅的方式为您的 class 定义内容。

The @Component function takes the configuration object and turns it into metadata that it attaches to the component class definition. Angular discovers this metadata at runtime and thus knows how to do "the right thing".

Read more here