-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Improve Stream.merge types #80
Comments
what is Anyway, why do you need to merge streams of different types? |
I agree with this suggestion, seems easy to do and we should do it. |
I can jump on this if no one objects. Two questions:
|
@xtianjohns good! We should do like Combine has: https://github.com/staltz/xstream/blob/master/src/core.ts#L135 |
xtianjohns
pushed a commit
to xtianjohns/xstream
that referenced
this issue
Jul 18, 2016
Modify static `merge` method to implement a new interface: MergeSignature. This interface is constructed similarly to the CombineSignature interface. Export the new interface. This change allows consumers invoking the static method to declare types and leverage TypeScript to verify type safety when merging streams. The change brings `merge` in line with other static methods which already include this feature. Related to staltz#80.
xtianjohns
pushed a commit
to xtianjohns/xstream
that referenced
this issue
Jul 19, 2016
Modify static `merge` method to implement a new interface: MergeSignature. This interface is constructed similarly to the CombineSignature interface. Export the new interface. This change allows consumers invoking the static method to declare types and leverage TypeScript to verify type safety when merging streams. The change brings `merge` in line with other static methods which already include this feature. Should resolve staltz#80.
staltz
pushed a commit
that referenced
this issue
Jul 20, 2016
Allows xs.merge(streamOfNumbers, streamOfStrings) to return a Stream of numbers or strings, as the return type in TypeScript. Modifis static `merge` method to implement a new interface: MergeSignature. This interface is constructed similarly to the CombineSignature interface. Export the new interface. This change allows consumers invoking the static method to declare types and leverage TypeScript to verify type safety when merging streams. The change brings `merge` in line with other static methods which already include this feature. PR #82. Should resolve #80.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using
Stream.merge
I found that I had to manually define the types since TS could not infer them with the current signature, which makes it of course error prone:From what I have seen so far to get variadic-ish generically typed arguments supported, we could use a function signature like this:
(I am pretty sure this works in .d.ts files, not sure how to annotate a function written directly in TS code with this though)
Code like this is often generated for up to 20 or 30 arguments, and then provides full type safety.
The text was updated successfully, but these errors were encountered: