I am trying to create Option objects based on the following typed interface:
interface Option {
/** Text for rendering */
label: string;
/** Value for searching */
value: string | number;
/**
* Allow this option to be cleared
* @default true
*/
clearableValue?: boolean;
}
Is it possible to convert the following to a single line?
const options = [1, 2, 3].map<Option>((t) => {
const option: Option = { label: String(t), value: String(t) };
return option;
});
I tried:
const options = [1, 2, 3].map<Option>((t) => Option = { label: String(t), value: String(t) });
but it doesn't work.