Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not specify explicit type parameters. Signatures with type parameters that cannot be inferred will be removed in v8. #4

Open
huan opened this issue Jul 27, 2020 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@huan
Copy link
Member

huan commented Jul 27, 2020

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

  1. rxjs fromEvent compatibility rxjs fromEvent compatibility andywer/typed-emitter#9
  2. Proposal: Statically typed fromEvent Proposal: Statically typed fromEvent ReactiveX/rxjs#4891
  3. typed-emitter compatibility typed-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

@huan huan added the enhancement New feature or request label Jul 27, 2020
huan added a commit that referenced this issue Mar 12, 2021
@huan huan added the bug Something isn't working label Mar 12, 2021
@huan 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
huan added a commit to wechaty/wechaty that referenced this issue Nov 7, 2021
huan added a commit to huan/state-switch that referenced this issue Nov 7, 2021
huan added a commit to huan/state-switch that referenced this issue Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant