Skip to content

[Bug]: [CocosCreator] Argument of type 'Room<MyRoomState>' is not assignable to parameter of type 'Room<Schema>'. Type 'MyRoomState' is missing the following properties from type 'Schema': [$getByIndex], [$deleteByIndex]ts(2345) #881

@yxdtg

Description

@yxdtg

Context

This is my code.

import { _decorator, Component, Node } from "cc";
const { ccclass, property } = _decorator;

import Colyseus from "db://colyseus-sdk/colyseus.js";
import type { MyRoomState } from "../../../../ColyseusServer/src/rooms/schema/MyRoomState";

@ccclass("Home")
export class Home extends Component {
    protected async start(): Promise<void> {
        const client = new Colyseus.Client("ws://localhost:2567");
        const room = await client.joinOrCreate<MyRoomState>("my_room");

        const $ = Colyseus.getStateCallbacks(room);
    }
}

This is the detailed error message.

Image Image
Argument of type 'Room<MyRoomState>' is not assignable to parameter of type 'Room<Schema>'.
  Type 'MyRoomState' is missing the following properties from type 'Schema': [$getByIndex], [$deleteByIndex]ts(2345)

using the Colyseus Multiplayer SDK from the Cocos Store, I found error messages in colyseus.d.ts, and it seems like the corresponding npm packages couldn’t be found, etc.

Image

I have also looked at this in detail, but unfortunately it did not solve the problem.
(#859 (comment))

Finally, I provided a minimal reproduction example.

Bug description

As mentioned above.

Reproduction

CocosColyseus.zip

Steps to reproduce

As mentioned above.

Environment & Versions

Colyseus-Client: 0.16.9
Colyseus-Server: 0.16.0
NodeJs: 22.19.0
Cocos: 3.8.7
TypeScript: 5.8.3
Os: Windows

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions