I have a props object that includes:
{
option1,
option2,
option3,
option4,
general,
otherProps
}
The requirement is to allow only one option to be used at a time. Here are the types defined:
interface MyTypes {
option1: boolean
option2: boolean
option3: boolean
general: boolean
otherProps: string
}
This is my attempt:
interface GeneralTypes{
general: boolean
otherProps: string
}
interface Option1Types{
option1: boolean
}
interface Option2Types{
option2: boolean
}
interface Option3Types{
option3: boolean
}
type MyTypes = GeneralTypes & (Option1Types | Option2Types | Option3Types)
However, I encounter this error:
Property 'option1' does not exist on type '(GeneralTypes & Option1) | (GeneralTypes & Option2)| (GeneralTypes & Option3)'
Property 'option2' does not exist on type '(GeneralTypes & Option1) | (GeneralTypes & Option2)| (GeneralTypes & Option3)'
Property 'option3' does not exist on type '(GeneralTypes & Option1) | (GeneralTypes & Option2)| (GeneralTypes & Option3)'