mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
typing_status: Use TypeScript unions for 'Recipient' type.
Typing 'Recipient' as union of 'stream' and 'direct' message type will help with upcoming type inference.
This commit is contained in:
@@ -4,16 +4,23 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
type RecipientUserIds<UserId: number> = $ReadOnlyArray<UserId>;
|
||||
type StreamTopicObject = {|stream_id: number, topic: string|};
|
||||
type DirectMessageObject<UserId: number> = {|
|
||||
message_type: string,
|
||||
ids: $ReadOnlyArray<UserId>,
|
||||
|};
|
||||
type StreamObject = {|
|
||||
message_type: string,
|
||||
stream_id: number,
|
||||
topic: string,
|
||||
|};
|
||||
|
||||
type Worker<UserId> = {|
|
||||
get_current_time: () => number, // as ms since epoch
|
||||
notify_server_start: (RecipientUserIds<UserId> | StreamTopicObject) => void,
|
||||
notify_server_stop: (RecipientUserIds<UserId> | StreamTopicObject) => void,
|
||||
notify_server_start: (DirectMessageObject<UserId> | StreamObject) => void,
|
||||
notify_server_stop: (DirectMessageObject<UserId> | StreamObject) => void,
|
||||
|};
|
||||
|
||||
declare export function update<UserId>(
|
||||
worker: Worker<UserId>,
|
||||
new_recipient: RecipientUserIds<UserId> | StreamTopicObject | null,
|
||||
new_recipient: DirectMessageObject<UserId> | StreamObject | null,
|
||||
): void;
|
||||
|
||||
Reference in New Issue
Block a user