Skip to content
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

Types of property '_ils' are incompatible. #316

Open
download13 opened this issue Oct 9, 2020 · 2 comments
Open

Types of property '_ils' are incompatible. #316

download13 opened this issue Oct 9, 2020 · 2 comments

Comments

@download13
Copy link

download13 commented Oct 9, 2020

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.

EDIT: Might be related to #262 (comment)

@wclr
Copy link
Contributor

wclr commented Oct 21, 2020

type Type1 = number
type Type2 = string

type CompoundType = Type1 | Type2;

const first: Type1 = 1;

const first$ = xs.of(first);

const x$: 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:

protected _ils: Array<InternalListener<T>>;
protected _dl: InternalListener<T>;

@staltz ?

related issues:
#286

@wclr
Copy link
Contributor

wclr commented Oct 22, 2020

I made a PR for this #317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants