IntelliJ and Angular 2 Argument Type Invalid Errors

Is Angular2 in IntelliJ (latest update v15 - Ultimate) that should work? All the docs seem to say that this happens through the AngularJS plugin, but I am getting really strange intellisense errors. For instance:

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 come across this before? Does anyone know how to make an intelliJ game enjoyable?

Source for application on request;

 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 { } 
+5
source share
2 answers

It turned out that for reasons that I cannot explain, a constructor is required, or IntelliJ is really confused, and the confusion goes through the whole chain of dependencies.

In my case, the fix was simple, by default, an empty constructor in the application:

 export class App { constructor() {} } 

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

+2
source

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

Meanwhile, you can use the EAP version.

+1
source

Source: https://habr.com/ru/post/1239757/


All Articles