Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

212
Vistas
Property 'cursor' does not exist on type X, null or undefined, using generated graphql type with Svelte #each

I was using SvelteKit without the amazing "strict": true in tsconfig.json until today.

I have this code generated (with codegen) from a Graphql schema that I cannot change:

export type PlayerListQuery = {
  __typename?: "Query";
  playerList: {
    __typename?: "PlayerConnection";
    edges?: Array<{
      __typename?: "PlayerEdge";
      cursor: any;
      node?: {
        __typename?: "Player";
        name?: string | null;
        age?: number | null;
        id: string;
      } | null;
    } | null> | null;
    pageInfo: {
      __typename?: "PageInfo";
      hasNextPage: boolean;
      hasPreviousPage: boolean;
      startCursor?: any | null;
      endCursor?: any | null;
    };
  };
};

which comes from this:

type PlayerConnection {
  totalCount: Int!
  pageInfo: PageInfo!
  edges: [PlayerEdge]
}

type PlayerEdge {
  cursor: Cursor!
  node: Player
}

and I'm using it like this in Svelte:

{#each $store.data.playerList.edges || [] as { cursor, node } (cursor)}
  {node?.name || "No name"}
  <br>
  {node?.age || "No age"}
{:else}
  Empty array!
{/each}

Now with the strict option the error is:

(parameter) cursor: any
Property 'cursor' does not exist on type '{ __typename?: "PlayerEdge" | undefined; cursor: any; node?: { __typename?: "Player" | undefined; name?: string | null | undefined; ... more ...; | undefined; } | null | undefined; } | null'.ts(2339)

both for cursor and node because it's right, they can be null or undefined.

What do you suggest to fix this?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda