-
Notifications
You must be signed in to change notification settings - Fork 18
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
module definition does not comply with ES6 modules and type definitions #78
Comments
I'm not quite understanding the problem ... how does this surface? The way you describe how it should be imported is the way that is recommended, and the way you say you have to import it will not actually work since multiple exports to not exist... Each type ( Can you put together a codebin example that showcases the problem? |
I'm writing the codebin, I think the problem lies on the Please check the thread babel/babel#2212 Another fix would be to change the typescript typings. at the end of the export default moize with export = moize |
Oh yes that creates the code you're talking about, I'm just not understanding the problem you describe with the result. Then implementing it in a variety of contexts, in has worked for me. EDIT: Also, what you are describing is only true of the import moize from 'moize/es'; |
I made a simple repository showing the problem It looks like babel inserts the |
Have you attempted what I recommended above? Importing instead from the import moize from 'moize/es'; This does not have the same export override as that in the |
I made the test and node throws an error since import its not supported on node yet. This fails on the simple repository.
|
So just so that I understand the context that you are having this problem in:
Is this correct? If so ... how can you consume any commonjs module? I don't use typescript, so I don't understand why it is assuming a EDIT: This issue has been discussed at length here: microsoft/TypeScript#2719 A possibility may be to provide an additional moize.default = moize; It feels janky, but it was one of the recommended courses of action and would solve this problem without breaking the current behavior. I'll experiment with this. |
So I just created a PR (feel free to take a look), but like I said I don't use TS (the typings were provided by the community) so this is mainly educated guesswork. If this doesn't do the trick, I may need to lean on you or the community at large for a PR to provide a more proper resolution. |
It look fine to me, I'll give it a test and summit another PR in case of any problem. Thanks! |
Cool, I'll merge and release tonight once I get home. |
Fix released as |
The way to import moize should be
Instead one have to import it as
Since the last two lines of the moize module are
Instead of simply
This does not comply with ES6 modules since a
default import
should return an object with adefault
property containing thedefault export
value instead of returning directly the exported valueThe text was updated successfully, but these errors were encountered: