I have an array in which every index item can be either IBusinessDetailCompetitor
or ICustomerCompetitorInstant
So can I do something ilke thiscustomerCompititorArray: (IBusinessDetailCompetitor[] | ICustomerCompetitorInstant[])
But this is giving errror. Please help.
The item in array should be union types :
interface IBusinessDetailCompetitor {
a: string
}
interface ICustomerCompetitorInstant {
b: string
}
const customerCompititorArrayCorrect: Array<IBusinessDetailCompetitor | ICustomerCompetitorInstant> = [{a: '1'}, {b: '2'}]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.