4 ms·
If all you need is a union type then the latter is plenty. If you need the actual strings to iterate over or validate against, deriving the value from an const
by braebo 2y ago
If all you need is a union type then the latter is plenty.
If you need the actual strings to iterate over or validate against, deriving the value from an const array is helpful:
const THINGS = ['one', 'two', 'three'] as const
type Thing = THINGS[number]