You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After having to manually change the JSON values of my types file every time I generate a new ones, it gets repetitive. It seems like it should possible to have those types replace automatically when the supabase gen types typescript is run.
Describe the solution you'd like
I'm not exactly sure how this would be approached, but it seems one possible solution would be to pass in a file path to a json file that mimics the organization of the generated types file, such as { [schemaName]: { .. "Tables": { .... [tableName]: { ....... [rowname]: string | number | boolean | null | { ............. ...typeJsonStructure .......... } | { ............. ...typeJsonStructure .......... }[] ...... } .. }, .. "Views": {}, .. "Functions": {}, }
An example file would be like { public: { Tables: { user: { myJsonColumn: { customParamOne: string customParamTwo: number } } }, Views: { userView: { viewJsonColumn: { viewColOne: string: viewColTwo: { nestedOne: boolean; nestedTwo: number | string' } } } } }
Describe alternatives you've considered
I have not seen anything related to JSON specifically, but @magick93 suggested support for Custom PostgreSQL types in this issue supabase/postgres-meta#840
The text was updated successfully, but these errors were encountered:
Hey @codewriter73, we've updated the docs to include the recommended way to merge/replace types. With this, you write the generated types to one file (e.g. database-generated.ts) and write the replacements in another file that imports the former (e.g. database.ts), so that way you don't have to keep manually replacing the types.
@soedirgo Thanks for pointing that out! I'll have to look into it more. I ended up writing my own script that uses typescript's compiler API to compare the generated DatabaseTypes.ts and my own AugmentTypes.ts to replace the types and output to a clean types file. I messed around with using abstract types to merge the two but I found it made it difficult to use typescript's language feature when trying to get a quick glance at the return types, etc
Feature request
After having to manually change the JSON values of my types file every time I generate a new ones, it gets repetitive. It seems like it should possible to have those types replace automatically when the
supabase gen types typescript
is run.Describe the solution you'd like
I'm not exactly sure how this would be approached, but it seems one possible solution would be to pass in a file path to a json file that mimics the organization of the generated types file, such as
{
[schemaName]: {
.. "Tables": {
.... [tableName]: {
....... [rowname]: string | number | boolean | null | {
............. ...typeJsonStructure
.......... } | {
............. ...typeJsonStructure
.......... }[]
...... }
.. },
.. "Views": {},
.. "Functions": {},
}
An example file would be like
{ public: { Tables: { user: { myJsonColumn: { customParamOne: string customParamTwo: number } } }, Views: { userView: { viewJsonColumn: { viewColOne: string: viewColTwo: { nestedOne: boolean; nestedTwo: number | string' } } } } }
Describe alternatives you've considered
I have not seen anything related to JSON specifically, but @magick93 suggested support for Custom PostgreSQL types in this issue supabase/postgres-meta#840
The text was updated successfully, but these errors were encountered: