Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

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 Aufrufe • vor 3 Jahren •via X (Twitter)

9 Kommentare

Profilbild von Gabriel Vergnaud
Gabriel Vergnaudvor 3 Jahren

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 😅

Profilbild von Gabriel Vergnaud
Gabriel Vergnaudvor 3 Jahren

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

Profilbild von Gabriel Vergnaud
Gabriel Vergnaudvor 3 Jahren

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

Profilbild von Gabriel Vergnaud
Gabriel Vergnaudvor 3 Jahren

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

Profilbild von Gabriel Vergnaud
Gabriel Vergnaudvor 3 Jahren

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

Profilbild von Gabriel Vergnaud
Gabriel Vergnaudvor 3 Jahren

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 👇

Profilbild von Luke Czyszczonik
Luke Czyszczonikvor 3 Jahren

I hope to give it a try soon🤞

Profilbild von Mark Ledwich
Mark Ledwichvor 3 Jahren

👏

Profilbild von qingyuano
qingyuanovor 3 Jahren

this library is awesome

Ähnliche Videos