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

debounce durationSelector param has incorrect typings #3164

Closed
patsissons opened this issue Dec 5, 2017 · 1 comment · Fixed by Xenira/Shashki#66
Closed

debounce durationSelector param has incorrect typings #3164

patsissons opened this issue Dec 5, 2017 · 1 comment · Fixed by Xenira/Shashki#66

Comments

@patsissons
Copy link

RxJS version:
5.5.3

Code to reproduce:

Observable
  .of('foo')
  .debounce(() => Observable.of('bar').delay(1000))
  .subscribe();

Expected behavior:
no compiler errors

Actual behavior:
error TS2345: Argument of type '() => Observable<string>' is not assignable to parameter of type '(value: string) => SubscribableOrPromise<number>'.

Additional information:
It looks like this was previously just working due to a type checking deficiency that has been corrected (not sure what has changed recently, possibly the 5.5.2 to 5.5.3 update?)

This can be easily patched by just projecting the duration selector to a number, but it's not very elegant and it make for very confusing looking observable composition.

Observable
  .of('foo')
  .debounce(() => Observable.of('bar').delay(1000).map(() => 0))
  .subscribe();

The debounce operator does not actually use the value of the duration selector, only its asynchrony to manipulate the debounce operator.

The proper typing should be durationSelector: (value: T) => SubscribableOrPromise<any> (or something more appropriate if any is not acceptable).

@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant