At present I am unable to access any of the properties from the "Eagle" class. I have imported my "AnyBird" type but when I try and use properties off of specifically "Eagle" it isn't recognized at all. It only sees the properties from "Bird".
I'd say "Just import Eagle as the type" but I need to have other more specialized types accepted as well. Like "Doves", "Pidgeons", "Chickens" for example. It needs to be extendable so I wanted to concatenate all of the types under "AnyBird".
Help would be super appreciated!
export type AnyBird = Bird | Eagle ;
export interface Eagle extends Bird {
energyGain: number;
heatGain: number;
energyCost: number;
heatCost: number;
}
export interface Bird {
id: number;
job: number;
jobSpecificId: number;
level: number;
}
An example would be in a separate file I'd be like:
import { AnyBird } from './common/skills/SpecialBirdsFile';
interface Props {
someBird: AnyBird;
}
export default class BirdThing extends Component<Props, State> {
state = {}
render() {
let {someBird} = this.props;
<div>
{allBirds.id} <-- WORKS!!!!!!
{allBirds.energyGain} <---- FAILS! Cannot be found.
</div>
}
}