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

ES6 import with TypeScript #117

Closed
nemanja-tosic opened this issue Jan 20, 2021 · 2 comments
Closed

ES6 import with TypeScript #117

nemanja-tosic opened this issue Jan 20, 2021 · 2 comments

Comments

@nemanja-tosic
Copy link

We are using TypeScript with "esModuleInterop": true.

Importing polly using the default export like so:

import polly from 'polly-js';

throws TypeError: polly_js_1.default is not a function at runtime.

If we try to use a namespace import:

import * as polly from 'polly-js';

Then we get TS2349: This expression is not callable. Type 'typeof polly' has no call signatures during compilation.

Help? :)
Thanks!

@nemanja-tosic
Copy link
Author

The runtime error was coming from tests, which have a project reference to the code in question. The tests did not have esModuleInterop set, whereas the project that was referenced did. Adding esModuleInterop to tests solved the issue for us. Not sure if there is a better way to address this though.

@mauricedb
Copy link
Owner

Ahh, I was about to ask you for a repo because I am using esModuleInterop all the time without problems. Guess I can close this then as the problem is solved.

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

No branches or pull requests

2 participants