supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.

Home Page:https://supabase.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`unknown` type for properties in two level deep nested query

samuba opened this issue · comments

Bug report

Describe the bug

When I do a query with a nested query inside a nested query the type for the second nested properties is unknown.

To Reproduce

So this query:

const { data } = await supabase
  .from('events')
  .select(`name,  guests: event_guests(attending, user: user_id(name))`)

Will result in the following type for the data variable. We see that guests.user.name is unknown but guests.attending is properly typed:

{
  name: string;
} & {
  guests: (
    { attending: string; } & 
    { user: { name: unknown; } | { name: unknown; }[]; }
  ) | (
    { attending: string; } & 
    { user: { name: unknown; } | { name: unknown; }[]; }
  )[];
}[]

Expected behavior

guests.user.name should have the proper type inferred. string in this example.

System information

  • Version of postgrest-js: 1.1.0
  • Version of supabase-js: 2.1.1