Zod EVERYWHERE (#2027)

* Zod EVERYWHERE

* Add no-unused-vars rule to eslint in front

* Add no-unused-vars rule to eslint in pusher

* Add no-unused-vars rule to eslint in back

* Remove unused PlayerTexture guards

* Fix data providing on room connection

Co-authored-by: Alexis Faizeau <a.faizeau@workadventu.re>
This commit is contained in:
Alexis Faizeau
2022-04-12 14:21:19 +02:00
committed by GitHub
parent 41e62051d4
commit d1e8243c47
161 changed files with 1131 additions and 1248 deletions
+4 -12
View File
@@ -1,14 +1,8 @@
import type * as tg from "generic-type-guard";
import type {
IframeEvent,
IframeEventMap,
IframeQuery,
IframeQueryMap,
IframeResponseEventMap,
} from "../Events/IframeEvent";
import { z } from "zod";
import type { IframeEvent, IframeQuery, IframeQueryMap, IframeResponseEventMap } from "../Events/IframeEvent";
import type { IframeQueryWrapper } from "../Events/IframeEvent";
export function sendToWorkadventure(content: IframeEvent<keyof IframeEventMap>) {
export function sendToWorkadventure(content: IframeEvent) {
window.parent.postMessage(content, "*");
}
@@ -48,12 +42,10 @@ export function queryWorkadventure<T extends keyof IframeQueryMap>(
});
}
type GuardedType<Guard extends tg.TypeGuard<unknown>> = Guard extends tg.TypeGuard<infer T> ? T : never;
export interface IframeCallback<
Key extends keyof IframeResponseEventMap,
T = IframeResponseEventMap[Key],
Guard = tg.TypeGuard<T>
Guard = z.ZodType<T>
> {
typeChecker: Guard;
callback: (payloadData: T) => void;