Closed andywer closed 4 years ago
And also creating generic class is helpful:
class MyEventEmitter<T> extends (EventEmitter as { new<T>(): TypedEmitter<T> })<T>
@andywer Thanks! But both you and I forgot to leave the class braces!😅
I am getting this error:
Conversion of type 'typeof EventEmitter' to type 'new () => TypedEventEmitter<TableEvents>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Type 'typeof EventEmitter' provides no match for the signature 'new (): TypedEventEmitter<TableEvents>'.
"events": "^3.2.0",
"typescript": "^3.9.7"
"typed-emitter": "^1.3.0"
Is there a particular events
package I should use?
@miracle2k You can fix this by casting default EventEmitter type to unknown
This should work (But I didn't test it)
class MyEventEmitter<T> extends (EventEmitter as unknown as { new<T>(): TypedEmitter<T> })<T> {
// ...
}
@erfanium Indeed, and I ended up doing that. Just wondering if people were doing something more cleaner, given that it wasn't mentioned in the README and related discussions.
@erfanium May events
module types from npm be different from node's native event
module types, Which has caused this problem
Thanks. That was exactly what I meant.