正在加载视频...

视频加载失败

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 次观看 • 3 年前 •via X (Twitter)

9 条评论

Gabriel Vergnaud 的头像
Gabriel Vergnaud3 年前

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 的头像
Gabriel Vergnaud3 年前

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

Gabriel Vergnaud 的头像
Gabriel Vergnaud3 年前

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

Gabriel Vergnaud 的头像
Gabriel Vergnaud3 年前

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

Gabriel Vergnaud 的头像
Gabriel Vergnaud3 年前

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

Gabriel Vergnaud 的头像
Gabriel Vergnaud3 年前

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 的头像
Luke Czyszczonik3 年前

I hope to give it a try soon🤞

Mark Ledwich 的头像
Mark Ledwich3 年前

👏

qingyuano 的头像
qingyuano3 年前

this library is awesome

相关视频