Loading video...
Video Failed to Load
I just published TS-Pattern v5! ๐ ๐ [_, โฆP.array()] variadic tuple patterns ๐ Builtin predicates for string and number patterns ๐ Chain `.optional`, `.or`, `.and`, and `.select` methods ๐ Improved type narrowing And more! ๐งต๐
33,319 views โข 3 years ago โขvia X (Twitter)
9 Comments

Variadic tuple patterns can take as many subpatterns as you want, both on the left side and the right side of ...P.array()! It was really challenging to implement ๐

Built-in predicates are super handy when creating zod-like schemas, especially coupled with `isMatching`:

Being able to chain `select` and `optional` modifiers is a very neat DX improvement because you get auto complete suggestions โจ

Type narrowing is even better! You no longer have to use `as const` anywhere:

If you want to upgrade from TS-Pattern v4, read this guide that goes through all breaking changes and new features:

Hope youโll enjoy this new version! I started working on it back in January 2022, I'm sooo glad to finally release it ๐ Find TS-Pattern on GitHub ๐

I hope to give it a try soon๐ค

๐

this library is awesome

