Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Exported typings are not a module #297

Closed

Description

@park9140

Exported external package typings file '**/node_modules/zone.js/dist/zone.js.d.ts' is not a module. Please contact the package author to update the package definition.

It appears that the typescript build is not outputting a module in it's definitions output.

Activity

  1. changed the title [-]Exprted typings are not a module[/-] [+]Exported typings are not a module[/+] on Mar 23, 2016
  2. park9140 commented on Mar 23, 2016

    @park9140
    Author

    This appears to be because the core file being built is not built as an external module. You need to have at least one import or export to create the external module.

  3. Nek- commented on Mar 24, 2016

    @Nek-

    I'm having same issue @park9140 did you fixed it ?

    If I don't import 'zone.js' my code does not work but if I do I get this error...

  4. park9140 commented on Mar 24, 2016

    @park9140
    Author

    @Nek- This works for now.

    declare module 'zone.js/dist/zone' {
        export var Zone; // this doesn't actually do anything just makes the compiler not complain about the empty module
    }
    declare module 'zone.js/dist/long-stack-trace-zone' {
        export var Zone; // this doesn't actually do anything just makes the compiler not complain about the empty module
    }
    import 'zone.js/dist/zone';
    import 'zone.js/dist/long-stack-trace-zone';

    long-stack-trace-zone is necessary because I am using angular 2.

  5. Nek- commented on Mar 24, 2016

    @Nek-

    @park9140 using your code generate a different error:

    src-js/app/main.ts(4,16): error TS2664: Invalid module name in augmentation, module 'zone.js/dist/zone' cannot be found.
    src-js/app/main.ts(7,16): error TS2664: Invalid module name in augmentation, module 'zone.js/dist/long-stack-trace-zone' cannot be found.
    

    But still an error.

  6. park9140 commented on Mar 24, 2016

    @park9140
    Author

    @Nek- One thing I forgot to mention that may cause a problem.

    The first part

    declare module 'zone.js/dist/zone' {
        export var Zone; // this doesn't actually do anything just makes the compiler not complain about the empty module
    }
    declare module 'zone.js/dist/long-stack-trace-zone' {
        export var Zone; // this doesn't actually do anything just makes the compiler not complain about the empty module
    }

    I have a in a separate .d.ts ambient definition. I'm not sure if those declares have to be in a .d.ts file. Also I'm using typescript 1.8.9.

    In addition I don't every import 'zone.js' directly anymore.

  7. Nek- commented on Mar 24, 2016

    @Nek-

    My bad ! I added a main.d.ts. It works like a charm. Thank you so much.

  8. Nek- commented on Mar 24, 2016

    @Nek-

    @park9140 well, I still get an error related to zone.js. I don't know why. But this is not critical (the app works)

    Anyway here is the message:

    Uncaught TypeError: Cannot read property 'cancelTask' of undefined
    
  9. sebilasse commented on Apr 8, 2016

    @sebilasse

    @Nek- Getting exactly the same error, also for other modules!
    Is main.ts the file where you import the zone.js stuff? Why do we need a d.ts now if it is already TS ?

  10. Nek- commented on Apr 17, 2016

    @Nek-

    @sebilasse idk why TS is asking for a d.ts when it's already in TS :/. But yes I put the fix in my main.ts file.

  11. alexeagle commented on Apr 24, 2016

    @alexeagle
    Contributor

    @robwormald discussed this with @mhevery this week, the reasoning for this is that zones are considered a polyfill, so you're expected to treat zone.js as an ambient dependency. Include zone.js.d.ts as an input to the typescript compilation, or use a ///<reference path=""/> to bring it into the compiler.

    Importing from it is not the suggested pattern, as that produces a value-side expression in the JS emit asking the module loader to load zone, and instead it should be included as a browser polyfill before the module loader starts.

    It's also tricky to get the right order - if you load zone.js after the module loader has started up, then the module loader or any previously loaded modules may hold a reference to un-patched async primitives, which will not be zone-aware.

    Closing as WAI, but please let me know if there's something we could do better here. Maybe import * as zone from 'zone.js'; should bring some symbols into scope?

  12. sap9433 commented on Apr 25, 2016

    @sap9433

    declare module 'zone.js/dist/zone' { export var Zone; // this doesn't actually do anything just makes the compiler not complain about the empty module }
    doesn't work , getting . Invalid module name in augmentation, module 'zone.js/dist/zone' cannot be found, though i vave zone.js module inside node_modeles

  13. rahmanusta commented on Jun 13, 2016

    @rahmanusta

    Hello, which version fixes this issue ? I removed the typings file in zone.js and installed typings with typings install dt~zone.js --save --global and it solves the issue, but there should be a way without workaround.

  14. added a commit that references this issue on Jul 5, 2016
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions