mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
submessage: Fix implicit use of any.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
a53fe206ea
commit
819bccfec1
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user