Consider this example:
const FIRST = "FIRST"
const SECOND = "SECOND"
type TOptions = FIRST | SECOND
const someFunction = (options: TOptions): void => {
// do something, no return
}
I like to use const values in type declaration
type TOptions = FIRST | SECOND // not working
to restrict the range of selection. These const are used across the entire project, so it will be unwise to not to use them and type it like this:
type TOptions = "FIRST" | "SECOND" // working, as expected
I don't want to repeat myself and like to use const
values as type union options.
How do I do that?