a373626e24
To do this, I used generic-type-guard package which generates both an interface AND a valid type guard from code. With this, we are 100% sure that the messages we receive are validated at runtime! The client cannot pass us an object that is invalid! \o/
10 lines
347 B
TypeScript
10 lines
347 B
TypeScript
import * as tg from "generic-type-guard";
|
|
import {isPointInterface} from "./PointInterface";
|
|
|
|
export const isJoinRoomMessageInterface =
|
|
new tg.IsInterface().withProperties({
|
|
roomId: tg.isString,
|
|
position: isPointInterface,
|
|
}).get();
|
|
export type JoinRoomMessageInterface = tg.GuardedType<typeof isJoinRoomMessageInterface>;
|