TypeScript as const keeps literal types
@mrnarwhal55▲ 5 net votes
const dirs = ['up', 'down'] as const types the array as a readonly tuple of those exact strings.
const dirs = ['up', 'down'] as const types the array as a readonly tuple of those exact strings.