Type Inference Flaw in `Stream` Module: Incorrect Handling of Union Types

Dear @Michael Arnaldi , @gcanti , @Tim Smart
I hope i missed something, but i think i've found some serious type design flaw at least in the Stream module, but i think
Effect
also have it.

Here is a short demonstration where value inside map project function incorrectly infers as never, because it goes SomeContainer<'1'> & SomeContainer<1> instead of SomeContainer<'1'> | SomeContainer<1>

import { Stream } from 'effect';

interface SomeContainer<Tag> {
    _tag: Tag;
}

declare function someSourceStream(): Stream.Stream<SomeContainer<'1'>> | Stream.Stream<SomeContainer<1>>

someSourceStream().pipe(Stream.map(value => {
    value;
    //^? never
}))


I worked with RxJS for years, and all this time i couldn't understand why do they use generics in such a weird way, and now i finally got it – it is required to make it work:)
As i can see – a lot of functions in effect/Stream requires type update, because right now it is just simply incorrect. What do you think about it?
Was this page helpful?