I have the following TypeScript interface:
interface SelectProps {
options: Option[];
value: string[];
onChange: (value: string[]) => void;
}
I want to add boolean called isMultiple that will change the types of the other properties.
When isMultiple=true
- enforce
value:string[] - enforce
onChange: (value: string[]) => void;
When isMultiple=false
- enforce
value:string - enforce
onChange: (value: string) => void;
Is it possible to dynamically set the type of other properties based on the value of one property?