gvergnaud
Type-Level TypeScript – Objects and Records
Re:Learn how to unleash the full potential of the type system of TypeS...
on Wednesday September 21, 2022 @08:23AM (#32923988)
Actually, this won't work with union types! The definition of `Equal` I use is this one:
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends < T >() => T extends Y ? 1 : 2 ? true : false;
Understanding this requires a bit more context, but I'll explain why we need something so complicated in the Advanced Union Types chapter :)
I picked it from https://github.com/type-challenges/type-challenges which is an awesome resource too
Re:Learn how to unleash the full potential of the type system of TypeS...
on Tuesday September 20, 2022 @05:43PM (#32918195)
It's actually not in the standard library, but you can write it yourself:
type Expect<T extends true> = T;
`T extends true` puts a type constraint on the parameter, which then needs to be assignable to the literal type `true` to type-check.
Re:Bringing Pattern Matching to TypeScript Introducing TS-Pattern v3.0
on Monday March 15, 2021 @05:53AM (#26464091)
Thanks! Hope you'll enjoy using it