Closed CarsonF closed 1 month ago
Currently:
const Status = makeEnum(...); Status.entry(...) // => { value: Status, label: string }
BUT if referencing the type generically:
const statusEnum: MadeEnum<Status>;
The entries didn't have a shape:
statusEnum.entry(...) // => empty object
Now they have the implicit shape:
statusEnum.entry(...) // => { value: Status, label: string }
Extra
This allows declaring extra entry declarations easier, by making it the second arg instead of third.
const statusEnum: MadeEnum<Status, { color: string }>; statusEnum.entry(...).color // => string
This Extra generic really has nothing to do with the enum functionality, it's just extra "statics". The type could be written as:
MadeEnum<Status> & { <Extras> }
Which we can still do now when needing to reference a generic enum with extra "statics".
I decided to keep the generic though as that helps TS infer how to emit the type.
const X = makeEnum(...); // X is represented as "MadeEnum<...>"
As opposed to some obtuse object literal shape.
https://seed-company-squad.monday.com/boards/5989610236/pulses/6766885746
Fix type to provide value & label from entries implicitly
Currently:
BUT if referencing the type generically:
The entries didn't have a shape:
Now they have the implicit shape:
Flip
Extra
positional genericThis allows declaring extra entry declarations easier, by making it the second arg instead of third.
This
Extra
generic really has nothing to do with the enum functionality, it's just extra "statics". The type could be written as:Which we can still do now when needing to reference a generic enum with extra "statics".
I decided to keep the generic though as that helps TS infer how to emit the type.
As opposed to some obtuse object literal shape.
https://seed-company-squad.monday.com/boards/5989610236/pulses/6766885746