@colyseus/schema 2.0.16 → 2.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colyseus/schema",
3
- "version": "2.0.16",
3
+ "version": "2.0.17",
4
4
  "description": "Binary state serializer with delta encoding for games",
5
5
  "bin": {
6
6
  "schema-codegen": "./bin/schema-codegen"
@@ -78,7 +78,7 @@
78
78
  "source-map-support": "^0.5.13",
79
79
  "ts-node": "^7.0.1",
80
80
  "tslib": "^2.1.0",
81
- "tsx": "^3.12.7",
81
+ "tsx": "^3.13.0",
82
82
  "typescript": "^5.0.4"
83
83
  },
84
84
  "nyc": {
package/src/Schema.ts CHANGED
@@ -898,7 +898,7 @@ export abstract class Schema {
898
898
  const schema = this._definition.schema;
899
899
  const deprecated = this._definition.deprecated;
900
900
 
901
- const obj: ToJSON<typeof this> = {};
901
+ const obj: unknown = {};
902
902
  for (let field in schema) {
903
903
  if (!deprecated[field] && this[field] !== null && typeof (this[field]) !== "undefined") {
904
904
  obj[field] = (typeof (this[field]['toJSON']) === "function")
@@ -906,7 +906,7 @@ export abstract class Schema {
906
906
  : this[`_${field}`];
907
907
  }
908
908
  }
909
- return obj;
909
+ return obj as ToJSON<typeof this>;
910
910
  }
911
911
 
912
912
  discardAllChanges() {
@@ -9,10 +9,10 @@ export type NonFunctionPropNames<T> = {
9
9
  [K in keyof T]: T[K] extends Function ? never : K
10
10
  }[keyof T];
11
11
 
12
- export type ToJSON<T> = Partial<NonFunctionProps<{
12
+ export type ToJSON<T> = NonFunctionProps<{
13
13
  [K in keyof T]: T[K] extends MapSchema<infer U>
14
14
  ? Record<string, U>
15
15
  : T[K] extends ArraySchema<infer U>
16
16
  ? U[]
17
17
  : T[K]
18
- }>>;
18
+ }>;