Loading video...

Video Failed to Load

Go Home

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,309 views • 3 years ago •via X (Twitter)

9 Comments

Gabriel Vergnaud's profile picture
Gabriel Vergnaud3 years ago

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 😅

Gabriel Vergnaud's profile picture
Gabriel Vergnaud3 years ago

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

Gabriel Vergnaud's profile picture
Gabriel Vergnaud3 years ago

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

Gabriel Vergnaud's profile picture
Gabriel Vergnaud3 years ago

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

Gabriel Vergnaud's profile picture
Gabriel Vergnaud3 years ago

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

Gabriel Vergnaud's profile picture
Gabriel Vergnaud3 years ago

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 👇

Luke Czyszczonik's profile picture
Luke Czyszczonik3 years ago

I hope to give it a try soon🤞

Mark Ledwich's profile picture
Mark Ledwich3 years ago

👏

qingyuano's profile picture
qingyuano3 years ago

this library is awesome

Related Videos