Typescript Error: EventEmitter is not a constructor function type.
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 https://github.com/geckosio/geckos.io/issues/22 or https://github.com/axios/axios/issues/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.
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!