staltz / xstream

An extremely intuitive, small, and fast functional reactive stream library for JavaScript
http://staltz.github.io/xstream/
MIT License
2.37k stars 137 forks source link

Can not flatten `MemoryStream` in typescript #248

Closed joemphilips closed 6 years ago

joemphilips commented 6 years ago

in xstream version 11.2.0 , when I tried

const test = xs.of(xs.of(null).startWith(null)).flatten();

I get the following error in.

The 'this' context of type 'Stream<MemoryStream<null>>' is not assignable to method's 'this' of type 'Stream<Stream<null>>'.
  Types of property '_ils' are incompatible.
    Type 'InternalListener<MemoryStream<null>>[]' is not assignable to type 'InternalListener<Stream<null>>[]'.
      Type 'InternalListener<MemoryStream<null>>' is not assignable to type 'InternalListener<Stream<null>>'.
        Type 'Stream<null>' is not assignable to type 'MemoryStream<null>'.

I found this when I tried to use HTTPDriver in cyclejs, because it requires to flatten() the response. and it has a same signature

I workaround by casting it to Stream<any> , but of course this is not Ideal. Please tell me if I'm missing something. Thanks!

staltz commented 6 years ago

That looks like a duplicate xstream installation. Can you run npm ls | grep xstream and see if you have other versions than 11.2.0?

joemphilips commented 6 years ago

Thanks for fast response. by running yarn list | grep xstream result was

│  │  └─ xstream@10.x || 11.x
│  └─ xstream@11.x
│  │  └─ xstream@10.x || 11.x
│  └─ xstream@11.x
│  └─ xstream@11.x
│  └─ xstream@10.x || 11.x
│  │  ├─ xstream@10.9.0
│  │  └─ xstream@10.x
│  └─ xstream@*
│  └─ xstream@^11.2.0
│  └─ xstream@>=10
│  ├─ xstream@^10.8.0
│  └─ xstream@10.9.0
│     └─ xstream@>=10
│  └─ xstream@^11.2.0
│  ├─ xstream@^11.2.0
├─ xstream@11.2.0

and the package which rely on only version 10 was @cycle/time@0.8.0 -> @cycle/run@1.0.0 and cycle-restart@0.2.3 I found that latest release of cycle-restart has not yet included this patch. So I'd better use build from the master branch in cycle-restart and this should be fixed. I really don't know what is the best way to use those unpublished version directly from the github, though.

By the way, thanks for this great library!

joemphilips commented 6 years ago

Yep. I released the new version of cycle-restart for myself and the issue has fixed. So closing now. thanks again!