这是我的第一个简单的 Hello World angular 2 应用程序,来自 Angular 2 quick start guide .
import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
@Component({
selector: 'ng2-app',
template: '<h1>My first Angular 2 App</h1>'
})
export class AppComponent { }
bootstrap(AppComponent);
当我使用 npm start 运行时,应用程序运行正常,但我的 IntelliJ IDE 在 bootstrap(AppComponent) 行中显示错误
Argument type AppComponent is not assignable to parameter type Type
查看bootstrap 函数声明,AppComponent 需要扩展Type。
export declare function bootstrap(appComponentType: Type, customProviders?: Array<any>): Promise<ComponentRef>;
我的问题是:
是否期望 Angular 组件扩展 Type?
最佳答案
我在 Intellij 2016.1.2 中通过 Angular 快速入门演示偶然发现了这一点。在 IDE 中设置以下选项有帮助:
关于javascript - Angular 2 引导函数给出错误 "Argument type AppComponent is not assignable to parameter type Type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34366797/