Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate concrete typescript types for JSON columns based on pg_jsonschema #834

Open
goszczynskip opened this issue Jun 10, 2024 · 0 comments

Comments

@goszczynskip
Copy link

goszczynskip commented Jun 10, 2024

When I create JSON checks on columns with pg_jsonschema it would be super cool to have it also in generated ts types.

Currently when I create the following table

CREATE TABLE public.some_table (
    id SERIAL PRIMARY KEY,
    arr jsonb not null check (
      jsonb_matches_schema ('{
        "type": "array",
        "items": {
           "type": "string"
         }       
      }',
      arr
      )
    )
);

Generating types with supabase gen types typescript produces the following types

...
arr: JSON
...

But I'd like to get

...
arr: string[]
...

Potentially it would be achievable by parsing passed schema in checks via a tool like https://github.com/bcherny/json-schema-to-typescript

Describe alternatives you've considered
I haven't found any other alternatives aligned with the current CLI architecture

Additional context
I don't know what I'd expect with more complex check expressions. Maybe ignore them and fall back to JSON.

@sweatybridge sweatybridge transferred this issue from supabase/cli Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant