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

esmock.d.ts export incorrect #110

Closed
jakebailey opened this issue Aug 14, 2022 · 6 comments · Fixed by #111
Closed

esmock.d.ts export incorrect #110

jakebailey opened this issue Aug 14, 2022 · 6 comments · Fixed by #111

Comments

@jakebailey
Copy link
Contributor

I tried importing esmock and got:

This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.

It looks like this d.ts file is handwritten; rather than what it currently says:

declare function esmock(path: string, localmock?: any, globalmock?: any): any;
export = esmock;

I believe this should actually read:

declare function esmock(path: string, localmock?: any, globalmock?: any): any;
export default esmock;

Which matches what TS would output for the code you've written in your js file. Playground Link

@iambumblehead
Copy link
Owner

@jakebailey would you make a PR? I would do this but am in the middle of something atm

@jakebailey
Copy link
Contributor Author

Sent #111.

(It'd be cool for this to be in TS from the start, or have a more complete d.ts file, but that's a different problem than me not being able to import it from my code at all.)

@iambumblehead
Copy link
Owner

We're in the process of dramatically improving the interpretation of esm import and export patterns and the changes should be ready in a few days. Please open an issue if you find anything in the current version of the package.

The PR will be published soonish -- thank you :)

@iambumblehead
Copy link
Owner

@jakebailey
Copy link
Contributor Author

Thanks, it's working now! (Besides a bug with relative module paths, which I'll try to report somehow.)

@iambumblehead
Copy link
Owner

@jakebailey hopefully a solution will come soon thanks for making this package better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants