Adding strong checks on messages exchanged using generic-type-guard
This commit is contained in:
parent
83fa23a82d
commit
5178dff108
5 changed files with 39 additions and 14 deletions
8
front/src/Api/Events/ChatEvent.ts
Normal file
8
front/src/Api/Events/ChatEvent.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import * as tg from "generic-type-guard";
|
||||
|
||||
export const isChatEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
message: tg.isString,
|
||||
author: tg.isString,
|
||||
}).get();
|
||||
export type ChatEvent = tg.GuardedType<typeof isChatEvent>;
|
Loading…
Add table
Add a link
Reference in a new issue