effect
effect copied to clipboard
Incorrect type inference on Match.type<Array>
What version of Effect is running?
3.15.2
What steps can reproduce the bug?
https://effect.website/play/#18a138640989
Match.type<Array-ish>() with Match.when([...stuff]) works fine with tuples but inference kinda fails with arrays.
type Item=string | number | null;
const match = Match.type<Array<Item>>().pipe(
Match.when(["A", Match.null], (a) => a),
// ^? same issue here
Match.orElseAbsurd,
);
const a = match(["A", null, 'b', 1])
// ^? ReadonlyArray<"A" | null>
// should be ["A", null, ...Array<Item>]
What is the expected behavior?
- I wanna see that first 2 elements are
"A"andnull- not an error but renders matching kinda useless - rest of the elements can be of any types actually, not just
"A" | null- this is an error
What do you see instead?
No response
Additional information
I have a suggested solution described here - the proposed solution is line 93 https://effect.website/play/#ef4051fe0011
I can issue a PR