[Bug]: `remoteRoomCall` does not infer the return type of the selected room method
Author: ColaFantaCreated Aug 9, 2026Updated Aug 10, 2026
Labels:bug: bug:eyes: triage
Bug description
matchMaker.remoteRoomCall() does not correctly infer the return type of the specific room method passed to it.
The current declaration is:
export declare function remoteRoomCall<TRoom = Room>(
roomId: string,
method: keyof TRoom,
args?: any[],
): Promise<ExtractMethodOrPropertyType<TRoom, typeof method>>Because method is typed as keyof TRoom, the selected method name is not preserved as the literal type 'getSeatsInfo'. As a result, the return type is calculated from all properties and methods of TRoom instead of only from TestRoom['getSeatsInfo'].
A possible fix is to introduce a separate generic parameter for the method key:
export declare function remoteRoomCall<
TRoom = Room,
TMethod extends keyof TRoom = keyof TRoom,
>(
roomId: string,
method: TMethod,
args?: any[],
): Promise<ExtractMethodOrPropertyType<TRoom, TMethod>>Steps to reproduce
- Define a room
class TestRoom extends Room {
getSeatsInfo() {
return [{ seatNo: 0, occupied: true }]
}
}- call using
remoteRoomCall
const seatsInfo = await matchMaker.remoteRoomCall<TestRoom>(
'room-id',
'getSeatsInfo',
)- the expected inferred type is:
{ seatNo: number; occupied: boolean }[]However, the inferred type is a broad union containing the types of other TestRoom members, such as:
string |
number |
boolean |
Client |
ClockTimer |
... |
undefinedEnvironment & Versions
- OS: macOS
- Node.js: 22.x
- Package manager: pnpm
- `@colyseus/core`: 0.17.49
- TypeScript: 5.xSource: colyseus/colyseus