Skip to content

Problems with stricter typing introduced in v2.47.11 #1351

Closed
@maximilian-hammerl

Description

@maximilian-hammerl

Bug report

Describe the bug

We have a lot of utility functions such as (simplified):

export async function deleteSomeData<
  Column extends string & keyof Tables<'some_data'>,
  Value extends Tables<'some_data'>[Column],
>(
  column: Column,
  value: Value,
): Promise<void> {
  const { error } = await supabase
    .from('some_data')
    .delete()
    .eq(column, value)

  if (error) {
    throw new Error(`Failed to delete some data: ${error.message}`)
  }
}

as well as more generic versions such as:

type PublicSchema = Database[Extract<keyof Database, 'public'>]
type PublicTables = PublicSchema['Tables']

export async function deleteEntity<
  TableName extends string & keyof PublicTables,
  Column extends string & keyof PublicTables[TableName]['Row'],
  Value extends PublicTables[TableName]['Row'][Column],
>(
  table: TableName,
  column: Column,
  value: Value,
): Promise<void> {
  const { error } = await supabaseAdmin
    .from(table)
    .delete()
    .eq(column, value)

  if (error) {
    throw new Error(`Failed to delete entity: ${error.message}`)
  }
}

which worked fine before 2.47.11, but with the stricter typing we get this error:

S2345 [ERROR]: Argument of type 'Value' is not assignable to parameter of type 'ResolveFilterValue<{ Tables: { ...'.
  Type '{ ...' is not assignable to type 'ResolveFilterValue<{ Tables: { ...'.
    Type '{ ...' is not assignable to type 'ResolveFilterValue<{ Tables: { ...'.
      Type '{ ...' is not assignable to type 'ResolveFilterValue<{ Tables: { ...'.
    .eq(column, value)

The error message is not helpful with debugging this problem and, so far, we were not able to fix this ourselves.

System information

  • Version of supabase-js: 2.47.11 and 2.47.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions