fix: function type generation for zero arg and scalar computed fields - #1035
fix: function type generation for zero arg and scalar computed fields#10357ttp wants to merge 3 commits into
Conversation
… computed field false positive
| !getTableNameFromRelationId(func.return_type_relation_id, func.return_type_id)) || | ||
| // OR if the function takes a table/view row (computed field) | ||
| tableAndViewNames.has(func.argument_types))) |
There was a problem hiding this comment.
I think this should already be covered by: https://github.com/supabase/postgres-meta/pull/1035/changes#diff-c903ec71df16a8ae5f665c19c21b273f74c2f8eb02f5e8a3552ebe69d18be18fR196-R198 🤔
| return fns | ||
| .map(({ fn, inArgs }) => { | ||
| let argsType = 'never' | ||
| let argsType = 'Record<PropertyKey, never>' |
There was a problem hiding this comment.
This needs to be tested with the inference within https://github.com/supabase/supabase-js/tree/master/packages/core/postgrest-js as I expect this might break a few things.
I remember having to use never specifically here to be able to detect the difference between actual functions with args, and functions with no args. Using a Record<string, never> in my memory didn't allowed that.
|
I am working on it, can you assign this issue to me. |
Co-authored-by: Andrew Valleteau <avallete@users.noreply.github.com>
|
We'd really love to see this land — we just hit a second, independent breakage from We run a JSON-schema validation test over our generated types: ts-json-schema-generator converts the Our workaround until this merges is injecting a custom node parser that rewrites createParser(program, config, (p) =>
p.addNodeParser({
supportsNode: (n) => n.kind === ts.SyntaxKind.NeverKeyword && ts.isPropertySignature(n.parent),
createType: () => new UnknownType(),
}),
)
|
Problems
never extends Tis always true)name_translated(products)are not added to Row typesSolution
Record<PropertyKey, never>instead ofneverfor zero-arg function ArgsRelated
Args: neverand names matching table columns cause columns to be omitted fromselect('*')return types #1039