Skip to content

fix(realtime): annotate Timer/Vsn getters to avoid deep phoenix imports - #2281

Merged
mandarini merged 1 commit into
developfrom
fix/realtime-dts-phoenix-deep-imports
Apr 27, 2026
Merged

mandarini merged 1 commit into
developfrom
fix/realtime-dts-phoenix-deep-imports

Conversation

@mandarini

@mandarini mandarini commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes type-checking failures for consumers using moduleResolution: NodeNext. The published .d.ts files in @supabase/realtime-js were inlining inferred return types via import("@supabase/phoenix/priv/static/types/timer") and import("@supabase/phoenix/priv/static/types/types"). @supabase/[email protected]'s exports map only publishes the root entry, so those deep paths fail to resolve and produce TS2307 errors unless consumers enable skipLibCheck.

What changed?

  • packages/core/realtime-js/src/RealtimeChannel.ts: added import type { Timer } from './phoenix/types' and annotated get rejoinTimer(): Timer.
  • packages/core/realtime-js/src/RealtimeClient.ts: added Timer and Vsn to the existing type-only import from ./phoenix/types and annotated get reconnectTimer(): Timer and get vsn(): Vsn.

Timer and Vsn are already re-exported from src/phoenix/types.ts, originating from the public root entry of @supabase/phoenix. With explicit annotations on the three getters, TypeScript's declaration emit references those names directly instead of falling back to import("...") against the original phoenix internal files.

Why was this change needed?

Without explicit return type annotations, TypeScript's declaration emit inferred the types and inlined them via import() pointing at the original definitions inside node_modules/@supabase/phoenix/priv/static/types/. Phoenix's exports map blocks resolution of those deep paths under NodeNext, so consumers got:

error TS2307: Cannot find module '@supabase/phoenix/priv/static/types/timer'
error TS2307: Cannot find module '@supabase/phoenix/priv/static/types/types'

Verified against the published @supabase/[email protected] tarball that the three offending lines were:

  • dist/module/RealtimeChannel.d.ts:169 → get rejoinTimer(): import("@supabase/phoenix/priv/static/types/timer").default;
  • dist/module/RealtimeClient.d.ts:76 → get reconnectTimer(): import("@supabase/phoenix/priv/static/types/timer").default;
  • dist/module/RealtimeClient.d.ts:77 → get vsn(): import("@supabase/phoenix/priv/static/types/types").Vsn;

After this fix, nx build realtime-js emits get rejoinTimer(): Timer;, get reconnectTimer(): Timer;, and get vsn(): Vsn; instead. A grep for phoenix/priv/static across dist/ returns zero matches.

This keeps phoenix's internal file layout private (preferred fix from the issue) rather than exposing it through phoenix's exports map.

Closes #2276

Screenshots/Examples

N/A. The change is in TypeScript declaration emit only.

Breaking changes

  • This PR contains no breaking changes

The runtime behavior is unchanged. The only effect is on the emitted .d.ts: the public return types (Timer, Vsn) are equivalent to what was previously inferred, just referenced via the public re-export rather than a deep path.

Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run npx nx format to ensure consistent code formatting
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable)

No new tests added: the fix is a pure type annotation change with no runtime behavior to test, and the existing 333 unit tests pass unchanged via nx test realtime-js. A regression test that greps the built .d.ts for phoenix/priv/static paths could be added as a follow-up if desired.

Additional notes

The reporter on #2276 also offered an alternative fix in @supabase/phoenix (publish subpath exports for ./priv/static/types/*). That alternative would unblock type-checking but bake phoenix's internal file layout into realtime-js's public contract. The annotation fix here is preferred and self-contained in this repo.

@mandarini
mandarini requested review from a team as code owners April 27, 2026 11:33
@github-actions github-actions Bot added the realtime-js Related to the realtime-js library. label Apr 27, 2026
@pkg-pr-new

pkg-pr-new Bot commented Apr 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@2281

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@2281

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@2281

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@2281

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@2281

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@2281

commit: c052db2

@mandarini mandarini self-assigned this Apr 27, 2026
filipecabaco
filipecabaco previously approved these changes Apr 27, 2026
@mandarini mandarini changed the title fix(realtime): annotate Timer/Vsn getters to avoid deep phoenix impor… fix(realtime): annotate Timer/Vsn getters to avoid deep phoenix imports Apr 27, 2026
@mandarini
mandarini changed the base branch from develop to master April 27, 2026 11:58
@mandarini
mandarini dismissed filipecabaco’s stale review April 27, 2026 11:58

The base branch was changed.

@mandarini
mandarini requested a review from a team as a code owner April 27, 2026 11:58
@mandarini
mandarini changed the base branch from master to develop April 27, 2026 11:58
@mandarini
mandarini merged commit cd513bb into develop Apr 27, 2026
26 of 27 checks passed
@mandarini
mandarini deleted the fix/realtime-dts-phoenix-deep-imports branch April 27, 2026 13:43
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.

realtime-js .d.ts deep-imports @supabase/phoenix/priv/static/types/* which phoenix's exports map doesn't publish

2 participants