News for hackers. Stuff that matters.
Re:Learn how to unleash the full potential of the type syste... by theteapot on Tuesday September 20, 2022 @06:02PM (#32918399)
OK cool, now what about `Equal` :).
Re:Learn how to unleash the full potential of the type syste... by triyambakam on Tuesday September 20, 2022 @06:37PM (#32918715)
type Equal<A, B> = A extends B ? (B extends A ? true : false) : false;
Re:Learn how to unleash the full potential of the type syste... by gvergnaud 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 syste... by theteapot on Tuesday September 20, 2022 @11:34PM (#32920575)
Nice.