Skip to content

Compilation fails with TypeScript 2.4.x #12233

Closed

Description

@RoopeHakulinen

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

Activity

  1. RoopeHakulinen commented on Jul 2, 2017

    @RoopeHakulinen
    Author

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

  2. RoopeHakulinen commented on Jul 2, 2017

    @RoopeHakulinen
    Author

    PR #12235 fixes this by explicitly typing the promise.

  3. jgw96 commented on Jul 3, 2017

    @jgw96
    Contributor

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

  4. vascofernandes commented on Jul 4, 2017

    @vascofernandes

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

     "compilerOptions": {
         ....
        "skipLibCheck": true,
        "noStrictGenericChecks": true,
        .....
    
    
  5. ssalasgx commented on Jul 7, 2017

    @ssalasgx

    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!

  6. RoopeHakulinen commented on Jul 7, 2017

    @RoopeHakulinen
    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.

  7. fiznool commented on Jul 10, 2017

    @fiznool

    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.

  8. mburger81 commented on Oct 2, 2017

    @mburger81
    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?

  9. RoopeHakulinen commented on Oct 2, 2017

    @RoopeHakulinen
    Author

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

  10. nour05 commented on Mar 20, 2018

    @nour05

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

  11. ionitron-bot commented on Sep 1, 2018

    @ionitron-bot

    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.

  12. locked and limited conversation to collaborators on Sep 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions