5

Is Angular2 in IntelliJ (latest update of v15 - Ultimate) supposed to work? All the docs seem to say that it does via the AngularJS plugin, but I'm getting really odd intellisense errors. For example;

bootstrap(App, [
    ROUTER_PROVIDERS,
    provide(LocationStrategy, {useClass: HashLocationStrategy})
]);

Throws  Argument type App is not assignable to parameter type Type

And standard annotations like;

@RouteConfig([
    {path: '/...', component: RootView, as: 'RootView', useAsDefault: true}
])

throw Argument type {path: string, component: RootView, as: string, useAsDefault: boolean}[] is not assignable to parameter type RouteDefinition[]

Has anyone run across this before? Anyone know how to make intelliJ play nice?

Source for App as requested;

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 {
}
XeroxDucati
  • 5,130
  • 2
  • 37
  • 66
  • 2
    while you are tying to bootstrap `App`, it should be a component of your application defined via @Component with proper selector, template and exporting a class. I would like to see the complete source if possible – Sage Jan 04 '16 at 04:55

2 Answers2

2

It turns out, for reasons I can not explain, that a constructor is required or IntelliJ gets really confused, and the confusion goes all the way down the dependency chain.

In my instance, the fix was simple, a default, empty constructor in App:

export class App {
    constructor() {}
}

But general rule of thumb in Angular2 with IntelliJ seems to be constructors on everything in the DI chain -- at least for the moment. I assume this is a bug and will be fixed in the angular plugin for IntelliJ -- I just submitted it to them.

XeroxDucati
  • 5,130
  • 2
  • 37
  • 66
1

According to JetBrains issue tracker this has been fixed, and will be no more problem from the upcoming version 2016.2

Meanwhile you may use EAP version.

Mick
  • 8,203
  • 10
  • 44
  • 66