Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!