I have too many conditions to run a function. is there any way I can simplify it with ts-pattern? #226
Answered
by
gvergnaud
raviteja83
asked this question in
Q&A
-
Is there a way in ts-pattern where I can eliminate a propery/value in each step and if I reach the final step, run whatever fn I want to. Here is an example: Thanks for the great work on the library. |
Beta Was this translation helpful? Give feedback.
Answered by
gvergnaud
Mar 2, 2024
Replies: 1 comment
-
You can pass several patterns to https://github.com/gvergnaud/ts-pattern?tab=readme-ov-file#matching-several-patterns https://github.com/gvergnaud/ts-pattern?tab=readme-ov-file#pintersection-patterns |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
raviteja83
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can pass several patterns to
.with
, or useP.intersection(...patterns)
https://github.com/gvergnaud/ts-pattern?tab=readme-ov-file#matching-several-patterns
https://github.com/gvergnaud/ts-pattern?tab=readme-ov-file#pintersection-patterns