Result type for .select() cannot be overridden. Since typings for nested relations is still a WIP, we need an escape hatch so people can set the types for specific fields.
What is the new behavior?
Support overriding the types for specific fields. E.g. from the tests:
// can override result type
{
const { data, error } = await postgrest
.from('users')
.select('*, messages(*)')
.returns<{ messages: { foo: 'bar' }[] }>()
if (error) {
throw new Error(error.message)
}
expectType<{ foo: 'bar' }[]>(data[0].messages)
}
Additionally, instead of always returning unknown for all nested relations, we instead return T | T[]. This is as specific as we can get despite the ambiguity.
What kind of change does this PR introduce?
feature
What is the current behavior?
Result type for
.select()
cannot be overridden. Since typings for nested relations is still a WIP, we need an escape hatch so people can set the types for specific fields.What is the new behavior?
Support overriding the types for specific fields. E.g. from the tests:
Additionally, instead of always returning
unknown
for all nested relations, we instead returnT | T[]
. This is as specific as we can get despite the ambiguity.