I have too many conditions to run a function. is there any way I can simplify it with ts-pattern? #226
-
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.
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.
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