Skip to content

Commit

Permalink
test(types): add TS validation to assure types are properly configured
Browse files Browse the repository at this point in the history
  • Loading branch information
oscard0m committed Mar 12, 2022
1 parent d857b47 commit d9a4210
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/typescript-validate.ts
@@ -0,0 +1,51 @@
import { Octokit } from "@octokit/core";
import { throttling } from "../src/index";
// ************************************************************
// THIS CODE IS NOT EXECUTED. IT IS FOR TYPECHECKING ONLY
// ************************************************************

const octokit = new Octokit();

// will be deprecated soon
// onAbuseLimit()
throttling(octokit, {
throttle: { enabled: true, onRateLimit: () => {}, onAbuseLimit: () => {} },
});

// onSecondaryLimit()
throttling(octokit, {
throttle: {
enabled: true,
onRateLimit: () => {},
onSecondaryRateLimit: () => {},
},
});

// onSecondaryLimit() and onAbuseLimit() should be a TS Error
// @ts-expect-error
throttling(octokit, {
throttle: {
enabled: true,
onRateLimit: () => {},
onSecondaryRateLimit: () => {},
onAbuseLimit: () => {},
},
});

// onRateLimit() missing should be a TS Error
// @ts-expect-error
throttling(octokit, {
throttle: {
enabled: true,
onSecondaryRateLimit: () => {},
},
});

// onSecondaryLimit() and onAbuseLimit() missing should be a TS Error
throttling(octokit, {
// @ts-expect-error
throttle: {
enabled: true,
onRateLimit: () => {},
},
});

0 comments on commit d9a4210

Please sign in to comment.