Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 bootstrap function gives error "Argument type AppComponent is not assignable to parameter type Type"

Here is my first simple Hello World angular 2 app from 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); 

The application runs fine when I run with npm start but my IntelliJ IDE is showing error in the line with bootstrap(AppComponent)

Argument type AppComponent is not assignable to parameter type Type

Angular 2 typescript warning

Looking at the bootstrap function declaration, AppComponent needs to extends Type.

export declare function bootstrap(appComponentType: Type, customProviders?: Array<any>): Promise<ComponentRef>; 

My question is:

Is it expected for Angular components to extend Type?

like image 695
TheKojuEffect Avatar asked Dec 19 '15 02:12

TheKojuEffect


2 Answers

I stumbled on this in Intellij 2016.1.2, with the Angular quickstart demo. Setting the following options in IDE helped:

enter image description here

like image 80
JockX Avatar answered Sep 22 '22 15:09

JockX


adding comment / annotation like shown below solves the problem

//noinspection TypeScriptValidateTypes bootstrap(AppComponent); 
like image 27
Otari Avatar answered Sep 20 '22 15:09

Otari