You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When mergeing streams of component types of a discriminating union the internal listener seems to be trying to assign a variable of the compound type to a variable of a component type.
You can see in the example repository I made that typechecking produces the following error:
index.ts:17:7 - error TS2322: Type 'Stream<FirstComponentType>' is not assignable to type 'Stream<CompoundType>'.
Types of property '_ils' are incompatible.
Type 'InternalListener<FirstComponentType>[]' is not assignable to type 'InternalListener<CompoundType>[]'.
Type 'InternalListener<FirstComponentType>' is not assignable to type 'InternalListener<CompoundType>'.
Type 'CompoundType' is not assignable to type 'FirstComponentType'.
Type 'SecondComponentType' is not assignable to type 'FirstComponentType'.
Basically, it seems like merge won't output types compatible with the CompoundType even when all of it's input stream are of component types. It works if merge contains all of the component types however. You can test it by adding second$ to the xs.merge call.
Is this intentional for a reason I don't understand, or is it a bug? I ran into it while converting DOM events into Actions to feed into my reducer function in a cyclejs app.
typeType1=numbertypeType2=stringtypeCompoundType=Type1|Type2;constfirst: Type1=1;constfirst$=xs.of(first);constx$: Stream<CompoundType>=first$;// this gives an error
This is due strictFunctionTypes enabled.
But probably it still should be considered as buggy behavior and as can be avoided. I see no reason why Stream<number> should not be actually not assignable to Stream<number | string>.
With xstream it is caused by having visible internal props with InternalListener<T> on the class:
When
merge
ing streams of component types of a discriminating union the internal listener seems to be trying to assign a variable of the compound type to a variable of a component type.You can see in the example repository I made that typechecking produces the following error:
Basically, it seems like
merge
won't output types compatible with theCompoundType
even when all of it's input stream are of component types. It works if merge contains all of the component types however. You can test it by addingsecond$
to thexs.merge
call.Is this intentional for a reason I don't understand, or is it a bug? I ran into it while converting DOM events into
Action
s to feed into my reducer function in a cyclejs app.EDIT: Might be related to #262 (comment)
The text was updated successfully, but these errors were encountered: