effect icon indicating copy to clipboard operation
effect copied to clipboard

`Match` pattern that should be recognized as exhaustive reports ts error

Open arekmaz opened this issue 1 year ago • 3 comments
trafficstars

What version of Effect is running?

3.4.6

What steps can reproduce the bug?

visit this playground url with the Match code, and corresponding working ts-pattern code to compare:

https://effect.website/play#b011033723ec

What is the expected behavior?

Match.exhaustive should not throw an error as the matchers are exhaustive

What do you see instead?

long ts error because the pattern is not recognized as exhaustive

image

Additional information

it's working correctly in the runtime, giving the same result as ts-patters just the type definition is different

arekmaz avatar Jul 08 '24 18:07 arekmaz

The way Match works is that it takes your pattern, and uses some internal type algo to remove it from the source type. Every match extends the union of patterns. It seems that because of how you model your data and your matchers, this causes and awkward situation. Sorry for that. Until this is resolved, i've attached a few ways to solve your issue here

datner avatar Jul 09 '24 01:07 datner

the second way is more than enough for me to solve my issue, thank you

arekmaz avatar Jul 09 '24 05:07 arekmaz

@arekmaz sorry to ping you here but I can't tag you it seems.. would you be interested in championing this?

datner avatar Jul 10 '24 09:07 datner