Update typescript typings for .sample() #536
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Update typescript types to support the case of one
value$
argument for.sample()
. It is a bit unclear in the documentation that this is supported as well but.sampleWith()
hints about it:Todo
No new functionality..
Just a simple change of wording.
Mapped types instead?
Would it be preferable to change to use mapped types where possible for all the instances where we have overloaded types because of variable number of arguments? Then we could support an arbitrary number of arguments without having to resort to overloads.
Mapped types has been around since TS 2.1. Will possibly need the improvements to rest/spread types that came later though (3.2). might be unrelated to my point
Example implementation
Could also have a helper type to box elements in all the functions that will need to implement this: