3 ms·
Typescript does have full unions, although only partially discriminated ones (in the sense that `number | string` is discriminated but `number | number` is not
by MrJohz 3y ago
Typescript does have full unions, although only partially discriminated ones (in the sense that `number | string` is discriminated but `number | number` is not - custom discriminators can be written fairly easily though). This resolves the problem that the previous poster had - nullability is not some magic trait of certain types, but rather a function of the general case of union types. In that case, `string | null` is no different from `string | number`, and null is just one possible type among many.
- cubefox 3y agoWhat does being "discriminated" mean here?
- HideousKojima 3y agohttps://en.m.wikipedia.org/wiki/Disjoint_union https://en.m.wikipedia.org/wiki/Disjoint_union