FroggyPanda / better-supabase-types

72 stars 13 forks source link

Issue parsing types from `supabase gen types` #31

Closed sangonzal closed 9 months ago

sangonzal commented 9 months ago

I'm seeing the following issue when running npx better-supabase-types -i types/supabase.ts -f

> common@1.0.0 supabase-types
> npx supabase gen types typescript --project-id *********> types/supabase.ts && npx better-supabase-types -i types/supabase.ts -f

/Users/santiago/.npm/_npx/269fea24060d8ca4/node_modules/@ts-morph/common/dist/ts-morph-common.js:438
            throw new InvalidOperationError(typeof errorMessage === "string" ? errorMessage : errorMessage(), node);
                  ^

InvalidOperationError: Expected to find interface named 'Database'.

This seems to be happening because npx supabase gen types is now returning a type, and better-supabase-types is looking for an interface. As far as I can I haven't updated the supabase cli, so not sure why the sudden change, but perhaps better-supabase-types should support both?

Here is the difference in types that is causing the issue:

Screenshot 2024-02-13 at 1 45 08 PM
FroggyPanda commented 9 months ago

oh that's an interesting change, ill get on a fix ASAP.

supersinex commented 9 months ago

Same issue here, thanks for looking into it, guys!

FroggyPanda commented 9 months ago

oh that's an interesting change, ill get on a fix ASAP.

If anyone is able to take a stab at converting the library from using an interface to a type that would be fantastic. I was, and still, unable to understand how ts-morph works and having a tough time finding documentation on how to actually traverse types and interfaces with that library.

kwbauson commented 9 months ago

I made a PR here with an attempt to support both interfaces and type aliases https://github.com/FroggyPanda/better-supabase-types/pull/32

sangonzal commented 8 months ago

@kwbauson @FroggyPanda Thanks for fixing!

Do you have any plans for releasing a new version to npm?