IntelliJ(v15-Ultimate的最新更新)中的Angular2应该工作吗?所有的文档似乎都说它是通过AngularJS插件实现的,但我收到了非常奇怪的intellisense错误。例如
bootstrap(App, [
ROUTER_PROVIDERS,
provide(LocationStrategy, {useClass: HashLocationStrategy})
]);
抛出 Argument type App is not assignable to parameter type Type
以及标准注释,如;
@RouteConfig([
{path: '/...', component: RootView, as: 'RootView', useAsDefault: true}
])
投掷Argument type {path: string, component: RootView, as: string, useAsDefault: boolean}[] is not assignable to parameter type RouteDefinition[]
以前有人碰到过这个吗?有人知道如何让intelliJ玩得好吗?
根据要求提供应用程序的来源;
import {Component, ViewEncapsulation} from 'angular2/core';
import {RootView} from './root-view';
import {
RouteConfig,
ROUTER_DIRECTIVES
} from 'angular2/router';
@Component({
selector: 'app',
templateUrl: './components/app/app.html',
encapsulation: ViewEncapsulation.None,
directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
{path: '/...', component: RootView, as: 'RootView', useAsDefault: true}
])
export class App {
}
事实证明,由于我无法解释的原因,构造函数是必需的,或者IntelliJ真的很困惑,这种困惑一直延续到依赖链。
在我的例子中,修复很简单,在App:中是一个默认的空构造函数
export class App {
constructor() {}
}
但是,使用IntelliJ的Angular2中的一般经验法则似乎是DI链中所有内容的构造函数——至少目前是这样。我认为这是一个错误,将在IntelliJ的angular插件中修复——我刚刚向他们提交了它。
根据JetBrains问题跟踪器,这一问题已经得到修复,并且在即将发布的2016.2 版本中不会有更多问题
同时您可以使用EAP版本。