I have auto-generated the types that are used for PokemonAPI (GraphQL) and I wanted to get the type for requirements attribute to use it as a function parameter type. When I try using `PokemonSpec[‘evoChain’] it generates an error
Property ‘evoChain’ does not exist on type ‘PokemonSpec’.
How do i do it?
export type PokemonSpec = {
__typename?: "pokemon_v2_pokemonspecies";
baseId?: number | null;
evoChain?: {
__typename?: "pokemon_v2_evolutionchain";
spec2: Array<{
__typename?: "pokemon_v2_pokemonspecies";
id: number;
name: string;
evolves_from_species_id?: number | null;
requirements: Array<{
needLevel?: number | null;
needHappiness?: number | null;
...
}>;
}>;
} | null;
} | null;
Link to the TS Playground
I have tried looking for answers on other posts but it’s mostly wrong spelling of attributes.
New contributor