Skip to content

Commit 2cc6318

Browse files
klardotshalexmv
authored andcommitted
types: Provide basic structural type hints for zulip-js.
1 parent 161f598 commit 2cc6318

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/zulip-js.d.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This is currently held in this repo as a testbed, but it should be migrated
2+
// to the zulip-js repo for broader use and tagged in a version bump at some
3+
// point soon.
4+
declare module "zulip-js" {
5+
export type ClientConfiguration =
6+
| { zuliprc: string }
7+
| {
8+
realm: string;
9+
username: string;
10+
apiKey?: string;
11+
};
12+
13+
export type ApiParameters = Record<string, any>;
14+
// This type can be narrowed once this file lives in zulip-js appropriately,
15+
// as Language Server Protocol is indicating hover-for-type support in that
16+
// repo on Response objects, including fields like json() and status.
17+
export type UntypedApiCall = (_: ApiParameters) => Promise<any>;
18+
19+
export type Client = {
20+
messages: ClientMessages;
21+
};
22+
23+
export type ClientMessages = {
24+
deleteById: UntypedApiCall;
25+
deleteReactionById: UntypedApiCall;
26+
flags: ClientMessagesFlags;
27+
getById: UntypedApiCall;
28+
getHistoryById: UntypedApiCall;
29+
render: UntypedApiCall;
30+
retrieve: UntypedApiCall;
31+
send: UntypedApiCall;
32+
update: UntypedApiCall;
33+
};
34+
35+
export type ClientMessagesFlags = {
36+
add: UntypedApiCall;
37+
remove: UntypedApiCall;
38+
};
39+
40+
async function zulipInit(arguments_: ClientConfiguration): Promise<Client>;
41+
export default zulipInit;
42+
}

0 commit comments

Comments
 (0)