-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as util from "util"; | ||
import * as assert from "assert"; | ||
import { nanoid } from "nanoid"; | ||
import { MapSchema, Schema, type, ArraySchema, defineTypes, Reflection, Context } from "../src"; | ||
|
||
describe("Community cases", () => { | ||
|
||
xit("colyseus/schema/issues/143", () => { | ||
class OptionalSubScheam extends Schema { | ||
@type('number') index: number = 200; | ||
@type('string') my_string: string = 'a good string'; | ||
} | ||
|
||
class Test extends Schema { | ||
@type('number') size: number = 0; // total number of storage slots in this container. | ||
@type('boolean') transient?: boolean; | ||
@type(OptionalSubScheam) sub?: OptionalSubScheam; | ||
} | ||
|
||
const testobj = new Test(); | ||
const encoded = testobj.encodeAll(false); | ||
const handshake = Reflection.encode(testobj); | ||
|
||
const clientobj = Reflection.decode<Test>(handshake); | ||
assert.strictEqual(clientobj.sub, undefined); | ||
}); | ||
|
||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as assert from "assert"; | ||
import { State, Player, DeepState, DeepMap, DeepChild, Position, DeepEntity } from "./Schema"; | ||
import { Schema, ArraySchema, MapSchema, type } from "../src"; | ||
|
||
describe("TypeScript Types", () => { | ||
it("strict null/undefined checks", () => { | ||
class Player extends Schema { | ||
@type("number") orderPriority: number; | ||
} | ||
class MyState extends Schema { | ||
@type({ map: Player }) players = new MapSchema<Player>(); | ||
} | ||
|
||
const state = new MyState(); | ||
state.players.set("one", new Player().assign({ | ||
orderPriority: null, | ||
})); | ||
state.encodeAll(); | ||
console.log("DONE!"); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.