Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
submessage: Fix implicit use of any.
Anders Kaseorg819bccfec16e
diff --git a/web/shared/src/poll_data.ts b/web/shared/src/poll_data.tsindex 6133bce215c..37dbb1a62aa 100644--- a/web/shared/src/poll_data.ts+++ b/web/shared/src/poll_data.ts@@ -30,16 +30,11 @@ export type WidgetData = {question: string;};-export type InboundData = Record<string, unknown> & {type: string};+export type InboundData = unknown;export type NewOptionOutboundData = {type: string; idx: number; option: string};export type QuestionOutboundData = {type: string; question: string};export type VoteOutboundData = {type: string; key: string; vote: number};export type PollHandle = {- // Add generic key property to allow string indexing on PollHandle type in `handle_event` method.- [key: string]: {- outbound: (arg: string) => InboundData | undefined;- inbound: (sender_id: number, data: InboundData) => void;- };new_option: {outbound: (option: string) => NewOptionOutboundData;inbound: (sender_id: number | string, data: InboundData) => void;@@ -294,8 +289,14 @@ export class PollData {}handle_event(sender_id: number, data: InboundData): void {+ assert(+ typeof data === "object" &&+ data !== null &&+ "type" in data &&+ typeof data.type === "string",+ );const type = data.type;- if (this.handle[type]) {+ if (type === "new_option" || type === "question" || type === "vote") {this.handle[type].inbound(sender_id, data);} else {this.report_error_function(`poll widget: unknown inbound type: ${type}`);diff --git a/web/src/submessage.ts b/web/src/submessage.tsindex a27c3fea333..80dc0923098 100644--- a/web/src/submessage.ts+++ b/web/src/submessage.ts@@ -79,7 +79,7 @@ export function get_message_events(message: Message): SubmessageEvents | undefinmessage.submessages.sort((m1, m2) => m1.id - m2.id);- const events = message.submessages.map((obj) => ({+ const events = message.submessages.map((obj): {sender_id: number; data: unknown} => ({sender_id: obj.sender_id,data: JSON.parse(obj.content),}));@@ -186,7 +186,7 @@ export function handle_event(submsg: Submessage): void {return;}- let data;+ let data: unknown;try {data = JSON.parse(submsg.content);