mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
Concretely, we'll use this with a `UserId` type which is an "opaque type alias" of `number` -- it's secretly implemented as simply `number`, and it can be consumed by anything that wants a `number` (in other words, it's a subtype of `number`), but the fact that it secretly just is `number` is private to the module that defines the type. As far as the typing_status code is concerned, allowing this to be a subtype of `number` just means that the code doesn't ever try to inject new numbers of its own into the recipients arrays that it passes around.
19 lines
426 B
Plaintext
19 lines
426 B
Plaintext
/**
|
|
* @flow strict
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
type RecipientUserIds<UserId: number> = $ReadOnlyArray<UserId>;
|
|
|
|
type Worker<UserId> = {|
|
|
get_current_time: () => number, // as ms since epoch
|
|
notify_server_start: RecipientUserIds<UserId> => void,
|
|
notify_server_stop: RecipientUserIds<UserId> => void
|
|
|};
|
|
|
|
declare export function update<UserId>(
|
|
worker: Worker<UserId>,
|
|
new_recipient: RecipientUserIds<UserId> | null
|
|
): void;
|