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

Generated TypeScript Types Issue: 'never' is Overridden by Other Types in Union Type #1288

Open
0xtz opened this issue Oct 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@0xtz
Copy link

0xtz commented Oct 19, 2024

Bug report

Description:

I'm encountering an issue with the generated TypeScript types when using Supabase. For the past 4 days, the types generated by the command supabase gen types typescript are producing TypeScript errors such as 'never' is overridden by other types in this union type. as indicated by SonarLint (typescript:S6571).

Supabase and Environment Details:

  • Supabase CLI Version: ^1.204.3
  • Project Setup: Using Next.js with standard TypeScript configuration
  • TypeScript Configuration: Default configuration provided by Next.js
  • Generation Command:
   supabase gen types typescript --project-id "XXXXXXXXXXXXXX" > src/lib/db_types.ts && prettier --write src/lib/db_types.ts

Error Details:

The error manifests in the generated file, specifically in union types where 'never' seems to be incorrectly set as the type.

Here’s a screenshot of the relevant section:
image

it's not an issue in 1 project No, its happening in 3 projects now, any idea ?

@0xtz 0xtz added the bug Something isn't working label Oct 19, 2024
@0xtz
Copy link
Author

0xtz commented Oct 19, 2024

If anyone is having this issue with Supabase's 'never' is overridden by other types in this union type., I found a temporary fix using ESLint overrides:

// Supabase `'never' is overridden by other types in this union type.` tmp fix
  overrides: [
    {
      files: ["src/lib/db_types.ts"], // Adjust this path to where your Supabase schema file is generated
      rules: {
        "@typescript-eslint/no-redundant-type-constituents": "off",
      },
    },
  ],

This solution disables the rule only for the generated file and prevents you from having to manually comment in the file every time it's regenerated. Hopefully, this can help while Supabase works on a permanent fix!

You can adjust the file path (src/lib/db_types.ts) as necessary before posting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant