You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{EventEmitter}from'events'importTypedEventEmitterfrom'typed-emitter'import{fromEvent}from'rxjs'interfaceEvents{foo: (n: number)=>voidbar: (s: string)=>void}constTypedEmitter=EventEmitterasnew()=>TypedEventEmitter<Events>constemitter=newTypedEmitter()fromEvent(emitter,'foo')// Error: Type 'TypedEventEmitter<Events>' is not assignable to type 'JQueryStyleEventEmitter'.
huan
changed the title
Type 'Puppet' is not assignable to type 'JQueryStyleEventEmitter'.
Do not specify explicit type parameters. Signatures with type parameters that cannot be inferred will be removed in v8.
May 31, 2021
When we start using typed-emitter, the event name is
string literal
instead ofstring
, which will run into The way fromEvent checks if the first argument passed is an emitter or not is incorrectMinimum Reproducible Code
Related Discussion
rxjs
fromEvent compatibilityrxjs
fromEvent compatibility andywer/typed-emitter#9fromEvent
Proposal: Statically typedfromEvent
ReactiveX/rxjs#4891typed-emitter
compatibilitytyped-emitter
compatibility devanshj/rxjs-from-emitter#4To be fixed.
Update June 1, 2021
With RxJS 7.1, we can remove
any
but still getunknown
.It seems that the
fromEvent
still not be able to infer fromon
/off
.Update Nov 7, 2021
Have sent a PR for fixing this issue to RxJS:
Related issues
The text was updated successfully, but these errors were encountered: