-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Type empty() with Stream<never> instead of Stream<any> ? #281
Comments
Updated typings so that empty() and never() have Stream<never> type, instead of Stream<any> type. staltz#281
Updated typings so that empty() and never() have Stream<never> type, instead of Stream<any> type. staltz#281
Hey @ryota-ka thanks for this thoughtful issue and the PR too. The reason I didn't answer yet was because this issue is not so obvious what's the right solution. I'm aware of
The problem with Actually the |
So are you talking about the variance of the generic parameter BTW, I came up with another typing, does it possibly work...? - static never(): Stream<any> {
- return new Stream<any>({ _start: noop, _stop: noop });
+ static never<T = never>(): Stream<T> {
+ return new Stream<T>({ _start: noop, _stop: noop });
|
Currently (as of v11.11.0)
empty()
returnsStream<any>
.xstream/src/index.ts
Lines 1305 to 1310 in 3181720
But IMO
Stream<never>
is more suitable here.For example, I ran into the following situation in Cycle.js.
If
Stream.empty()
was typedStream<never>
,foo
would retain its original type.concerns
never
type was introduced already in TypeScript v2.0 (almost 3 years ago)The text was updated successfully, but these errors were encountered: