Skip to content

Commit ab7bbab

Browse files
committed
test(types): add TS validation to assure types are properly configured
1 parent 5ccd50f commit ab7bbab

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

test/typescript-validate.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Octokit } from "@octokit/core";
2+
import { throttling } from "../src/index";
3+
// ************************************************************
4+
// THIS CODE IS NOT EXECUTED. IT IS FOR TYPECHECKING ONLY
5+
// ************************************************************
6+
7+
const octokit = new Octokit();
8+
9+
// will be deprecated soon
10+
// onAbuseLimit()
11+
throttling(octokit, {
12+
throttle: { enabled: true, onRateLimit: () => {}, onAbuseLimit: () => {} },
13+
});
14+
15+
// onSecondaryLimit()
16+
throttling(octokit, {
17+
throttle: {
18+
enabled: true,
19+
onRateLimit: () => {},
20+
onSecondaryRateLimit: () => {},
21+
},
22+
});
23+
24+
// onSecondaryLimit() and onAbuseLimit() should be a TS Error
25+
// @ts-expect-error
26+
throttling(octokit, {
27+
throttle: {
28+
enabled: true,
29+
onRateLimit: () => {},
30+
onSecondaryRateLimit: () => {},
31+
onAbuseLimit: () => {},
32+
},
33+
});
34+
35+
// onRateLimit() missing should be a TS Error
36+
// @ts-expect-error
37+
throttling(octokit, {
38+
throttle: {
39+
enabled: true,
40+
onSecondaryRateLimit: () => {},
41+
},
42+
});
43+
44+
// onSecondaryLimit() and onAbuseLimit() missing should be a TS Error
45+
throttling(octokit, {
46+
// @ts-expect-error
47+
throttle: {
48+
enabled: true,
49+
onRateLimit: () => {},
50+
},
51+
});

0 commit comments

Comments
 (0)