Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match pattern that should be recognized as exhaustive reports ts error #3199

Open
arekmaz opened this issue Jul 8, 2024 · 3 comments
Open
Labels
bug Something isn't working

Comments

@arekmaz
Copy link
Contributor

arekmaz commented Jul 8, 2024

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 arekmaz added the bug Something isn't working label Jul 8, 2024
@datner
Copy link
Member

datner commented Jul 9, 2024

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

@arekmaz
Copy link
Contributor Author

arekmaz commented Jul 9, 2024

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

@datner
Copy link
Member

datner commented Jul 10, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants