`unknown` type for properties in two level deep nested query
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
Hey there !
We've reworked the result inference in postgrest-js to address the typing issues mentioned above. The changes are available in a canary release, and we're actively seeking your feedback.
To test it out, update your supabase-js to version 2.46.0-rc.1 (which includes postgrest-js 1.17.0-rc.1):
npm install [email protected]
Please let us know if you encounter any issues, especially with retro-compatibility, so we can finalize it for the next release.
The fix has been released in supabase-js v2.46.0. I'm closing this issue, but feel free to reopen if you encounter any further errors.