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

Select sub-type for exhaustive check. E.g. .exhaustive(([state, event]) => event.type) #212

Open
audunolsen opened this issue Jan 8, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@audunolsen
Copy link

The docs' reducer example and its usage of exhaustive doesn't seem that helpful. When matching a complex data type like a tuple consisting of two unions with 4 entries each, a true exhaustive check would need to handle 16 possible combinations. Explicitly handling all those cases wouldn't be meaningful. As the docs state:

only a subset of these events make sense for each given state

What is actually happening in the example is that each value for event.type is manually exhaustively checked. If you add a new event type in the given reducer example then there would be no ts error indicating you need to handle a new event type.

It would be extremely helpful to select a subtype of the matched pattern which should be exhaustively checked.

E.g. something like

match([state, event]).exhaustive(([state, event]) => event.type)

Amazing work! 🌟 Happy new year

@audunolsen audunolsen added the enhancement New feature or request label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant