Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails with TypeScript 2.4.x #12233

Closed
RoopeHakulinen opened this issue Jul 2, 2017 · 11 comments
Closed

Compilation fails with TypeScript 2.4.x #12233

RoopeHakulinen opened this issue Jul 2, 2017 · 11 comments

Comments

@RoopeHakulinen
Copy link

Ionic version: (check one with "x")
[ ] 1.x (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[x] 3.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

App does not compile with TypeScript 2.4.x since

typescript: ...ments/GitHub/Helvar/AA-mobile/node_modules/ionic-angular/components/nav/nav.d.ts, line: 47 
            Class 'Nav' incorrectly extends base class 'NavControllerBase'. Types of property 'goToRoot' are
            incompatible. Type '(opts: NavOptions) => Promise<any>' is not assignable to type '(opts: NavOptions) =>
            Promise<never>'. Type 'Promise<any>' is not assignable to type 'Promise<never>'. Type 'any' is not
            assignable to type 'never'.

      L47:  export declare class Nav extends NavControllerBase implements AfterViewInit, RootNode, INav {
      L48:      private _root;

[18:44:08]  typescript: ...ents/GitHub/Helvar/AA-mobile/node_modules/ionic-angular/components/tabs/tab.d.ts, line: 121 
            Class 'Tab' incorrectly extends base class 'NavControllerBase'. Types of property 'goToRoot' are
            incompatible. Type '(opts: NavOptions) => Promise<any>' is not assignable to type '(opts: NavOptions) =>
            Promise<never>'. Type 'Promise<any>' is not assignable to type 'Promise<never>'.

     L121:  export declare class Tab extends NavControllerBase implements ITab {
     L122:      private _cd;

Expected behavior:

Steps to reproduce:

Related code:

insert any relevant code here

Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

insert the output from ionic info here
@RoopeHakulinen
Copy link
Author

RoopeHakulinen commented Jul 2, 2017

This is caused by Promise.reject returned from NavControllerBase's method goToRoot. I'll take a look at fix and possibly submit a PR.

@RoopeHakulinen
Copy link
Author

PR #12235 fixes this by explicitly typing the promise.

@jgw96
Copy link
Contributor

jgw96 commented Jul 3, 2017

Hello @RoopeHakulinen , thanks for using Ionic and thanks for the PR! We will look into getting this merged.

@jgw96 jgw96 added the v2 label Jul 3, 2017
@vascofernandes
Copy link

add this to tsconfig.json temporarily until the issue is fixed:

 "compilerOptions": {
     ....
    "skipLibCheck": true,
    "noStrictGenericChecks": true,
    .....

@ssalasgx
Copy link

ssalasgx commented Jul 7, 2017

Hi, i suddenly had a problem like that, and i didn't know why, i will share the screen
error_navcont
I checked ionic info:
error_nav2

And i try the solution from vascofernandes and it works, please can you explain how does it work?

Best regards!

@RoopeHakulinen
Copy link
Author

It works because in TS 2.4 there was an addition to the compiler that improves generics checking. In this case it relates to checking the generic Promise<T> better. The problem is that the base class' (NavControllerBase) method returns Promise<never> while the child class' (NavController) overrides this method and returns Promise<any>. These two types are different starting from TS 2.4 and thus the compilation error.

@fiznool
Copy link

fiznool commented Jul 10, 2017

Would love to see this PR merged soon! tslint is causing a load of erroneous warnings with ts 2.3.4 due to this issue.

@mburger81
Copy link
Contributor

@RoopeHakulinen is it save to use TS 2.4.2 on [email protected], we have som libs which requires >2.4 but I saw ionic is for example reverting TS from 2.5.x back again to 2.3.4 so it seems > 2.3.4 should not work properly?

@RoopeHakulinen
Copy link
Author

I haven't had a chance to update yet myself so unfortunately can't tell you that :( @jgw96 probably knows

@nour05
Copy link

nour05 commented Mar 20, 2018

it still does not work for me what I have to do!!

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 1, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants