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
[x] Unit tests for new or changed APIs and/or functionality
No new functionality..
[x] Documentation, including examples
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
sample<B extends unknown[], R>(
fn: (...b: B) => R,
...b: { [T in keyof B]: Stream<B[T]> }
): Stream<R>;
Could also have a helper type to box elements in all the functions that will need to implement this:
type StreamBoxed<T> = { [K in keyof T]: Stream<T[K]> };
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
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: