Closed evanshortiss closed 2 years ago
Thanks for reporting, @evanshortiss!
No, we shouldn't update the readme, this is definitely a bug we need to fix 😕
Maybe a quick fix could be to declare __events
as an optional property.
@huan Thoughts?
@andywer I have been facing the same issue and I'm using the same workaround as @evanshortiss did:
I have thought about this for some time but have no better ideas yet.
@huan What about this?
Maybe a quick fix could be to declare __events as an optional property.
Maybe a quick fix could be to declare __events as an optional property.
This works for me. I guess it might be a bit awkward for devs using FromEvent
? Another option might be to create a separate interface for the FromEvent typing? Something like this maybe?
export interface TypedFromEmitter extends TypedEventEmitter { __events: Events }
I think creating a separate interface might be clearer for the solution, and it will not introduce any unexpected behavior for the user who does not need this feature.
Attempting to create a class that extends EventEmitter per the README fails:. For example:
The error reported is:
This appears to happen due to these lines to support FromEvent. Removing those fixes the issue.
Casting to
unknown
first will resolve the issue, i.eclass Foo extends EventEmitter as unknown as new () => TypedEmitter<MyEvents>
is working fine.Should the documentation be updated?