Gabriel Vergnaud
banner
gabrielvergnaud.com
Gabriel Vergnaud
@gabrielvergnaud.com
TypeScript nerd • Open Source (TS-Pattern, HOTScript) • Teacher • Staff Eng @datadog

Unleash TypeScript's full potential 👉 http://type-level-typescript.com
A new version of TS-Pattern is out 🚨

You can now customize the fallback behavior of `.exhaustive()` if the runtime value you get is unexpected.

upgrade 👉 npm i ts-pattern@5.7.0
March 28, 2025 at 8:50 PM
Here is another reason I like Type Catalogs.

They can easily be transformed with Mapped Types!

Full code snippet in thread 🧵👇
February 23, 2025 at 4:26 PM
You need to understand how unions distribute over conditional types to fully get why `Extract` works. Its definition can be somewhat cryptic:
February 22, 2025 at 8:44 PM
yea ultimately unions and catalogs encode the same information so either option works!

To extract a member of a discriminated union, I find that using the builtin Extract utility is the simplest, but I've noticed that the way Extract works isn't immediately intuitive to most people
February 22, 2025 at 8:44 PM
And lastly, it makes writing generic function types so much easier!

No need for pesky `Extract`s or `Exclude`s 🔥
February 22, 2025 at 5:03 PM
Secondly, you can generate sub-unions super easily:
February 22, 2025 at 5:03 PM
Firstly, having a catalog greatly decreases the number of type imports you need to make:
February 22, 2025 at 5:03 PM
Pro tip: Don't write your #TypeScript union types by hand, use a Type Catalog instead!

Why are Type Catalogs better?

Find out in the thread 🧵 👇
February 22, 2025 at 5:03 PM
A new TS-Pattern release is out!

👉 Prevent passing impossible patterns to `isMatching` when used with 2 parameters.
👉 `P.infer` behaves better when used in an argument position.

just run `npm i ts-pattern@v5.6.0` in your project 😊

Release note: github.com/gvergnaud/ts...
December 15, 2024 at 10:26 PM
Type-Level TypeScript is on sale for Black Friday! 🚨

You can get it for 25% off! It's only 74$ to get lifetime access to all course materials.

👉 type-level-typescript.com

Enroll to learn how to craft and transform #TypeScript *types* with the same ease you handle JavaScript values every day!
November 26, 2024 at 3:51 PM
Template Literal Types are awesome.

If you concat `number` and a union of time units, you have a human readable AND type-safe way to provide time values! 👇
November 14, 2024 at 12:30 AM