-
Notifications
You must be signed in to change notification settings - Fork 440
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
Uncaught TypeError: mitt is not a constructor #60
Comments
Webpack loads the ES6 Source (because I think mitt points to it by default), you will need to override the main in mitt's |
Hi there - don't import * as mitt, just import it directly: import mitt from 'mitt'; |
That works with just Webpack but it won't work with just Typescript, when running tests etc. |
@developit "[ts] Module '"mitt"' has no default export." |
We are converting a component that uses mitt from JavaScript to TypeScript. I installed the last version, 1.1.3, but still encountering "mitt is not a constructor". Followed the TypeScript approach mentioned. Any recommendations on resolving would be appreciated? |
Here is how you can work around the issue for now without messing with Webpack.
|
For folks encountering this: you need to set {
"compilerOptions": {
"allowSyntheticDefaultImports": true,
}
} Update: I'm adding a comment in the type definitions pointing to this issue with an explanation of the cause. |
Hi!
Im trying to use mitt in our react project using typescript.
But I get this error in runtime:
I'm using ut just like in your example
When debugging in Dev tools and check mitt it's an object, not a contructor.
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: