supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
3.2k stars 258 forks source link

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

Open 0xtz opened 2 hours ago

0xtz commented 2 hours ago

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 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 commented 2 hours ago

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!