Property ‘x’ does not exist on type ‘y’ (Graphql Codegen)

Property ‘x’ does not exist on type ‘y’ (Graphql Codegen)


0

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

Ian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *