**Type Inference Differences Between Effect.reduce and Array.reduce**
Hey folks! I encountered an interesting type inference issue and I'm curious about why Effect.reduce behaves differently than Array.reduce.
I have nested reducers inside
With
When I used
Adding an explicit return type annotation to
Why does
Thanks!
I have nested reducers inside
Effect.gen with a helper function that returns a literal union type:With
Array.reduce, TypeScript widened the return type to a union where the only difference between both variants was that utilizationLevel was string in one variant and "high" | "medium" | "low" in the other, creating a union type error:When I used
Effect.reduce for both nested reduces, this type error didn't occur.Adding an explicit return type annotation to
getUtilizationLevel fixed the issue with Array.reduce:Why does
Effect.reduce handle type inference better than Array.reduce in this nested context? Is there something about how Effect's type signatures are designed that helps TypeScript narrow types more effectively?Thanks!
