I have 2 variables:
let locals
let visitants
Each of them can be of type PlayerDto or TeamDto. Type will depend on third variable called competitor_type. If competitor_type is player then I would need to assign a list of Players to locals and visitants, other ways a list of teams.
I am solving it using "any"
locals: any
teams: any
Is there a better way of solving it?
competitor_typeanother variable?let locals: PlayerDto | TeamDtothen have an if statement to check if the value is of a specific typeif(locals instanceof PlayerDto) {} else if(locals instanceof TeamDto){}