-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
When we start using typed-emitter, the event name is string literal
instead of string
, which will run into The way fromEvent checks if the first argument passed is an emitter or not is incorrect
Minimum Reproducible Code
import { EventEmitter } from 'events'
import TypedEventEmitter from 'typed-emitter'
import { fromEvent } from 'rxjs'
interface Events {
foo: (n: number) => void
bar: (s: string) => void
}
const TypedEmitter = EventEmitter as new () => TypedEventEmitter<Events>
const emitter = new TypedEmitter()
fromEvent(emitter, 'foo')
// Error: Type 'TypedEventEmitter<Events>' is not assignable to type 'JQueryStyleEventEmitter'.
Related Discussion
rxjs
fromEvent compatibilityrxjs
fromEvent compatibility andywer/typed-emitter#9- Proposal: Statically typed
fromEvent
Proposal: Statically typedfromEvent
ReactiveX/rxjs#4891 typed-emitter
compatibilitytyped-emitter
compatibility devanshj/rxjs-from-emitter#4
To be fixed.
Update June 1, 2021
With RxJS 7.1, we can remove any
but still get unknown
.
It seems that the fromEvent
still not be able to infer from on
/off
.
Update Nov 7, 2021
Have sent a PR for fixing this issue to RxJS:
Related issues
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request