Skip to content

RoomEventCallbacks type is not exported from public API #1685

@tsforge

Description

@tsforge

Select which package(s) are affected

@livekit/components-react

Describe the bug

Description
The RoomEventCallbacks type is defined in livekit-client/src/room/Room.ts but is not exported from the main package entry point, making it impossible to use in TypeScript projects without importing from internal paths.

Reproduction

// ❌ Does not work - type not exported
import { RoomEventCallbacks } from 'livekit-client';

// ❌ Does not work - cannot import from internal structure
import type { RoomEventCallbacks } from 'livekit-client/dist/src/room/Room';
// Error: Cannot find module 'livekit-client/dist/src/room/Room' or its corresponding type declarations

// ✅ Should work
import { RoomEvent, RoomEventCallbacks } from 'livekit-client';

type MyEventMap = {
[key in RoomEvent]?: RoomEventCallbacks[key];
};

Use Case

We're building custom hooks that need to type-check event callbacks for events. The type is essential for creating type-safe event listeners. Room``RoomEventCallbacks

// Our use case
export const useRoomListeners = (events: Partial) => {
const room = useRoomContext();

useEffect(() => {
Object.entries(events).forEach(([event, callback]) => {
if (callback) {
room.on(event as RoomEvent, callback);
}
});
// ... cleanup
}, [events, room]);
};

Proposed Solution
Export RoomEventCallbacks from livekit-client/src/index.ts:
export * from './room/Room'

Additional Context
The type exists in the compiled .d.ts files (node_modules/livekit-client/dist/src/room/Room.d.ts) but TypeScript's module resolution doesn't allow importing from these internal paths in a reliable way.

Logs

System Info

System:
    OS: macOS 26.0.1
    CPU: (16) arm64 Apple M4 Max
    Memory: 983.88 MB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.6.0 - /Users/apple/.nvm/versions/node/v24.6.0/bin/node
    npm: 11.5.1 - /Users/apple/.nvm/versions/node/v24.6.0/bin/npm
  Browsers:
    Chrome: 141.0.7390.66
    Safari: 26.0.1
  npmPackages:
    @livekit/components-react: ^2.3.3 => 2.9.15

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions