Add __ctx to Messages for optional comments. Move ServerMessage.ts up

This commit is contained in:
Tobias Berger 2022-01-08 16:21:02 +01:00
parent 7746e3ebdd
commit f7cfeb92bd

View file

@ -4,6 +4,7 @@ export enum MessageType {
} }
export type ServerMessage = { export type ServerMessage = {
__ctx?: string;
type: MessageType; type: MessageType;
date: number; date: number;
}; };
@ -31,6 +32,13 @@ export function isServerMessage(
) { ) {
return false; return false;
} }
if (
Object.hasOwnProperty.call(obj, "__ctx") &&
typeof (obj as { __ctx: unknown }).__ctx !== "string" &&
typeof (obj as { __ctx: unknown }).__ctx !== "undefined"
) {
return false;
}
return true; return true;
} }