Open coeing opened 1 year ago
I have the same problem. I found the following works for me:
import { type EventMap } from "typed-emitter";
type TypedEventEmitter<Events extends EventMap> = import("typed-emitter").default<Events>;
The problem seems to be assigning an interface to the module object via the default export
. I think the issue would be fixed with the following:
- interface TypedEventEmitter<Events extends EventMap> {
+ export interface TypedEventEmitter<Events extends EventMap> {
This should conserve backwards compatibility while allowing the following:
import { EventMap , TypedEventEmitter } from "typed-emitter";
I have the same issue.
Our workaround is:
import TypedEventEmitter, { EventMap } from "typed-emitter";
type TypedEmitter<T extends EventMap> = TypedEventEmitter.default<T>;
Getting this error when importing the library the way it is written in the documentation:
Cannot use namespace 'TypedEmitter' as a type.
The code which is working for me looks like this:
Maybe it has something to do with the fact that my application is compiled as ESM?