6 ms·
I've found this to be quite ergonomic and functional for handling string enumerations (including completeness in switches and record definitions): https://gith
by mceachen 2y ago
I've found this to be quite ergonomic and functional for handling string enumerations (including completeness in switches and record definitions):
https://github.com/photostructure/fs-metadata/blob/main/src/string_enum.ts https://github.com/photostructure/fs-metadata/blob/main/src/...
Usage:
export const Directions = stringEnum("North", "South", "East", "West")
export type Direction = StringEnumKeys<typeof Directions>
(I haven't published this as a discrete npm package--IMHO you should copy and paste this sort of thing into your own tree).