Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: MapSchema does not works without any @type #179

Open
Andrek25 opened this issue Aug 14, 2024 · 1 comment
Open

[Bug]: MapSchema does not works without any @type #179

Andrek25 opened this issue Aug 14, 2024 · 1 comment

Comments

@Andrek25
Copy link

Andrek25 commented Aug 14, 2024

Bug description

In v2.0 we can have a MapSchema without any @type but it's not working for v3.0, i know there is not sense to have a Schema if you won't sync any data, but i was using it because in future i'll sync some data.

This is a problem in v3.0 so the stackblitz project won't fail, there is a example code:

export class MySchema extends Schema {
}

export class MyRoomState extends Schema {
  @type({ map: MySchema }) mySchema: MapSchema<MySchema> = new MapSchema<MySchema>();
}

export class MyRoom extends Room<MyRoomState> {
  onJoin() {
    this.state.mySchema.set('foo', new MySchema()); // <- Fail
  }
}

To make this example to work i just need to remove @type({ map: MySchema }).

Optional: Minimal reproduction

There is not a stackblitz project with v3.0

Here is an image to track the error:

image

@endel
Copy link
Member

endel commented Aug 14, 2024

Thank you for reporting @Andrek25 - Just fixed it on @colyseus/[email protected] 🙌

endel added a commit that referenced this issue Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants