In ts, I want the parameter of a function to be either a or b, for example:
let func = (str) => {}
// str can only be equal to one of'top' and'end'
I have been unable to find a solution.
In ts, I want the parameter of a function to be either a or b, for example:
let func = (str) => {}
// str can only be equal to one of'top' and'end'
I have been unable to find a solution.
let func = (str: 'top' | 'end') => {};
You are looking for string literal types in combination with union types.