How to match both on type (instance of) and property values #71
Unanswered
snowfrogdev
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey, I was thinking of implementing pattern matching myself when I stumbled upon your wonderful project. Very cool. And I'm hoping it'll save me from having to roll out my own thing, if I even have enough drive to do it 😁. Now...
Given this:
Using ts-pattern, how do I do something functionally equivalent to this:
I think you get what I'm trying to do. The same kind of pattern matching that you would do on Result and Option types in rust. I've used a class hierarchy here but if it helps in any way, I could do this instead:
Beta Was this translation helpful? Give feedback.
All reactions