Hi @endel
Okay I figured out how to do. I had this trouble and I am using plain JS, which adds more trouble :p (and I hadn't read the documentation about State, I have to admit)
So, if anyone has the same trouble, here is a solution for plain Javascript :
import { Room } from "colyseus";
// Imports need to be done with require for Schema
const schema = require('@colyseus/schema');
const { defineTypes, Schema } = schema;
export class TestState extends Schema {
foo = "bar";
anything = "you want"
}
export class TestRoom extends Room {
onCreate(options) {
this.setState(new TestState());
}
}
// This is the important part
defineTypes(TestState, {
whatever: "string"
});
Thanks for the help !