News for hackers. Stuff that matters.
Re:TypeScript 3.5 by marton78 on Thursday May 30, 2019 @06:54AM (#20049936)
This is still a discriminated union, only that the discriminator is provided by Javascript and is thus hidden: it's `typeof`.
Re:TypeScript 3.5 by tomp on Thursday May 30, 2019 @08:17AM (#20050387)
Yeah, that's the runtime perspective... but for the type system, they're different... with the "naked" union being much harder (as they're non-algebraic - `a | b | b` always equals `a | b` and might even equal just `a` for some values of `a` and `b`)
Re:TypeScript 3.5 by spion on Thursday May 30, 2019 @12:09PM (#20052632)
No, this works on any overlapping types too - even unsound combinations such as `T | Array<T>`