Skip to content

Conversation

@7ttp
Copy link
Contributor

@7ttp 7ttp commented Dec 23, 2025

Adds a generic overload for on() with postgres_changes that accepts any event type, enabling reusable subscription helpers with union types like '*' | 'INSERT' | 'UPDATE' | 'DELETE'.

Fixes "No overload matches this call" error when passing generic event parameters to channel.on('postgres_changes', ...).

closes #1451

@7ttp 7ttp requested review from a team as code owners December 23, 2025 22:19
@7ttp 7ttp changed the title fix(realtime): add generic overload for postgres_changes event type fix(realtime) : add generic overload for postgres_changes event type Dec 23, 2025
@coveralls
Copy link

coveralls commented Dec 23, 2025

Coverage Status

coverage: 95.349% (+14.0%) from 81.389%
when pulling eaf16ef on 7ttp:fix/realtime11
into 30f9600 on supabase:master.

@mandarini mandarini changed the title fix(realtime) : add generic overload for postgres_changes event type fix(realtime): add generic overload for postgres_changes event type Jan 5, 2026
@mandarini
Copy link
Contributor

@7ttp thank you for this PR. Can you please add a test for the new functionality? It can go in packages/core/realtime-js/test/RealtimeChannel.postgres.test.ts. Something like:

...
      const event: '*' | 'INSERT' | 'UPDATE' | 'DELETE' = 'INSERT'
      // This should compile without errors (previously required `as any`)
      channel.on(
        'postgres_changes',
        {
          event,
          schema: 'public',
          table: 'users',
        },
...
      )
...
      expect(channel.bindings.postgres_changes.length).toBe(1)
...

@mandarini mandarini self-assigned this Jan 5, 2026
Copy link
Contributor

@mandarini mandarini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested test!

@mandarini mandarini added the realtime-js Related to the realtime-js library. label Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

realtime-js Related to the realtime-js library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to subscribe to different table update event determined during runtime in typescript

3 participants