Hacker News new | ask | show | jobs
by o11c 478 days ago
The problem with "just use literal strings/numbers" is that that's exactly the opposite of type safe. With them it is impossible to specify an argument of type `myenum | number | string`, despite that being commonly desired in some form.

When targeting javascript, it seems to me that the obvious approach is to use symbols for enums. But symbols have a lot of WET.

(of course, typescript's safety is unfixably broken in numerous other ways, so why bother?)