Gabriel Vergnaud Profile picture
TypeScript nerd • Author of TS-Pattern • Teacher • Staff Eng @datadoghq Learn how to 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!