Gabriel Vergnaud Profile picture
TypeScript nerd β€’ Author of TS-Pattern β€’ Staff Eng @datadoghq Unleash TypeScript's full potential πŸ‘‰ https://t.co/0GmYbCJKEj
Jan 9, 2023 β€’ 4 tweets β€’ 2 min read
TS-Pattern's inference just got a bit smarter!

βœ… Unreachable branches do not type-check anymore
βœ… `.with ` and `.otherwise` inherit type narrowing from previous branches
βœ… ~15% type-checking performance improvement

Release note πŸ‘‰ github.com/gvergnaud/ts-p… This is not a breaking change!

If your project doesn't type-check after upgrading, it's probably that you had duplicated/unreachable code branches.

If you think it's a bug feel free to open an issue here πŸ‘‰ github.com/gvergnaud/ts-p…
Jan 2, 2023 β€’ 8 tweets β€’ 4 min read
Implementing a get function that narrows union types and rejects invalid paths is tricky.

But it's doable if you know some type-level programming!

Want to become a #TypeScript expert in 2023?

Here is what you need to know to type this function
πŸ‘‡ First, you need a precise understanding of how assignability works in TypeScript.

Types like `never` or `unknown` are super useful, but often misunderstood!

The second chapter of Type-Level TypeScript covers this in depth (you can read it for free!)

type-level-typescript.com/types-are-just…
Aug 29, 2022 β€’ 8 tweets β€’ 3 min read
TS-Pattern is over 3K ⭐️ on GitHub now! This is nuts 🀯

I started TS-Pattern as an experiment to see how far the type system of #TypeScript could go.

Here are 4 of my favorites features I've built into TS-Pattern! πŸ§΅πŸ‘‡ Image First, keep in mind that Pattern Matching is usually a language feature.

Trying to make a library as good as native support is challenging! A key aspect of this is type inference.

The features I'll talk about have little to no runtime. It's only types!