Release note π
github.com/gvergnaud/ts...
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
Love it! These sound effects are just perfect β€οΈ
And here is a TypeScript Playground with the full code snippet
π
www.typescriptlang.org/play/#code/F...
I also have a full chapter about advance uses for Mapped Types in my TypeScript course, check it out: type-level-typescript.com/mapped-types
Mapped Types are a super powerful feature that you can learn about in TypeScript docs: www.typescriptlang.org/docs/handboo...
Here is another reason I like Type Catalogs.
They can easily be transformed with Mapped Types!
Full code snippet in thread π§΅π
You need to understand how unions distribute over conditional types to fully get why `Extract` works. Its definition can be somewhat cryptic:
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
I started using this pattern in one of my codebases a year ago and never looked back.
If you are also a heavy user of unions of objects, give it a try!
And lastly, it makes writing generic function types so much easier!
No need for pesky `Extract`s or `Exclude`s π₯
Secondly, you can generate sub-unions super easily:
Firstly, having a catalog greatly decreases the number of type imports you need to make:
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 π§΅ π
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...
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!
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! π
Thanks @ayc0.github.io! β€οΈπ
Hey friends π
Trying out @bsky.app, looks great so far!
I'll post TypeScript and programming related things.
to get started, here is an article I wrote a couple of weeks ago explaining how to get optional keys from object types π€
type-level-typescript.com/articles/how...