Replies: 1 comment
-
Sorry for the late reply, but with TS-Pattern v5, you can now use const text = match(value)
.with(
{ text: P.string.minLength(1) },
selected => selected.text
)
.otherwise(() => placeholder) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What's the recommended way to ensure a value is a string and not empty:
I'm matching an object with structure
{ text: string }
but I need to ensure thetext
string is also not empty. If it's empty, I still want theotherwise
method to trigger.So far, it seems like this is what I need to do, I don't see any shorter ways:
Beta Was this translation helpful? Give feedback.
All reactions