Typescript Error Ionic 2

3

Next Error:

  

Type 'typeof LoginPage' is not assignable to type 'typeof HomePage'.

Code:

import { LoginPage } from '../pages/login/login';

if(user) {
  this.rootPage = HomePage;
} else {
  this.rootPage = LoginPage; // Erro nessa linha
}
    
asked by anonymous 18.11.2016 / 19:18

2 answers

0

Only fix the variable declaration:

import { LoginPage } from '../pages/login/login';

let rootPage:Any;

if(user) {
  this.rootPage = HomePage;
} else {
  this.rootPage = LoginPage; // Erro nessa linha
}
    
22.02.2017 / 22:59
0

Declare:

rootPage: any;

Confirm the data type of the rootPage attribute. As in this case you will only know what the run-time component is going to need to pass at compile time.

TypeScript Docs - Any: link

This is a very interesting project to use as a code sample: link

    
29.11.2016 / 18:33