Hacker News new | past | comments | ask | show | jobs | submit login

> it doesn't play well if you're using Literals instead of Enums as the discriminator type

The original example code with Enums doesn't type-check either, and for the same reason:

If the type checker allowed that, someone could take an object of type Foo, assign it to a variable of type _FrobulatedBase, then use that variable to modify the kind field to 'bar' and now you have an illegal Foo with kind 'bar'.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: