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

Emitter expression is not constructable #47

Open
gustavojb92 opened this issue Feb 20, 2023 · 1 comment
Open

Emitter expression is not constructable #47

gustavojb92 opened this issue Feb 20, 2023 · 1 comment

Comments

@gustavojb92
Copy link

gustavojb92 commented Feb 20, 2023

I'm a starter and I hope you beg my pardon cuz maybe I'm looking a little stupid for you, but, I can't solve that problem.
I created a util called bus, and I am trying to use the Emitter with TS :

import Emitter from "tiny-emitter";

export default new Emitter();

but I received that error:

This expression is not constructable.
  Type 'typeof import("C:/projeto Controle Financeiro/wa-controle-financeiro/node_modules/tiny-emitter/index")' has no construct signatures.

I hope you can help me.

@ameerjahanap
Copy link

ameerjahanap commented May 17, 2023

The error occurred because the class is exported as named export whereas you imported it as a default import. So instead of
import Emitter from "tiny-emitter"; , you should import it as import { TinyEmitter } from "tiny-emitter"; according to the d.ts file.

Edit: The d.ts file from the npm registry is incomplete compared to the file on github. Hence the error. Otherwise import Emitter from "tiny-emitter"; should work!

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