Files
zulip/static/shared/js/typing_status.js.flow
Greg Price 0de1d03dd4 typing_status: Mark recipient array as allowing number subtypes.
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.
2020-12-30 14:55:24 -08:00

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;