Skip to content

Check beta ​

TypeAlias of @v12-engine/engine

ts
export type Check<T> = (value: unknown, path: string) => T;

Checkers for what comes in from the outside, like the commands of a player. On a server that is whatever anyone sends, so nothing is taken on trust: a checker either hands back the value as the type it promises, or throws Invalid saying what is wrong with it, and where (td.intro.lanes[2].items[0].at is a number): the commands of a player, a cinematic's file, a lane's own items and the game's other files are checked by these alike.

ts
const fields = { building: id, unitType: string, queue: optional(bool) }
type Fields = Checked<typeof fields> // { building: number; unitType: string; queue?: boolean }