Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


What does being "discriminated" mean here?





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: