Consider a type declaration like:
type PackageManagers = 'pnpm' | 'yarn' | 'npm'
Later, I need to provide a list of options as a string array like: ['pnpm', 'yarn', 'npm']
I don't like this repetition -- is there an expression that creates the list of values from the type (or vice versa)?
(I guess I'm thinking along the lines of an Java Enum.values.)
Additionally, consider that I have a map like:
const commands = {
pnpm: "pnpm do something",
yarn: "yarn do something",
npm: "npm do something"
}
And then a new Package Manager option like bun is added. Is there a way to flag commands because it is incomplete because it is missing a bun element?