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

Typescript Error: EventEmitter is not a constructor function type. #46

Open
trival opened this issue May 4, 2024 · 1 comment
Open

Comments

@trival
Copy link

trival commented May 4, 2024

After upgrading to latest version of elementary and typescript, I am getting the error in the title from typescript.

The error occurs in line 76 of node_modules/@elemaudio/core/dist/index.d.ts that says:

declare class export_default extends EventEmitter<EventTypes> {
    constructor();
}

I therefore can't use any EventEmitter functions on the WebRenderer object without typescript complaining.

My project uses "type": "module" in package.json, and "moduleResolution": "Node16" in tsconfig.json (because of some other typescript errors from other libraries).

After looking at similar issues on Github, like geckosio/geckos.io#22 or axios/axios#6225, it seems that changing

import EventEmitter from 'eventemitter3';
to
import { EventEmitter } from 'eventemitter3';

should fix this error. It at least fixed the error when I changed that code in the published node_modules/@elemaudio/core/dist/index.d.ts.

If that would work for you and cause no other troubles, maybe it is worth to use the direct import syntax of EventEmitter.

Actually running the code using vite works by the way, it is only typescript complaining.

@nick-thompson
Copy link
Contributor

Thanks @trival, and sorry for the delay. This is good to know; I'll be revisiting much of the js frontend libraries shortly and will loop this change in with that effort!

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