-
Notifications
You must be signed in to change notification settings - Fork 317
/
Copy pathtypes.ts
70 lines (61 loc) · 1.97 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import type * as OctokitTypes from "@octokit/types";
import type { RequestError } from "@octokit/request-error";
import type { Octokit } from "./index.js";
export type RequestParameters = OctokitTypes.RequestParameters;
export interface OctokitOptions {
// TODO: add types for authStrategy & auth options and octokit.auth() method,
// see https://tinyurl.com/typescript-auth-strategies
authStrategy?: any;
auth?: any;
userAgent?: string;
previews?: string[];
baseUrl?: string;
log?: {
debug: (message: string) => unknown;
info: (message: string) => unknown;
warn: (message: string) => unknown;
error: (message: string) => unknown;
};
request?: OctokitTypes.RequestRequestOptions;
timeZone?: string;
[option: string]: any;
}
export type Constructor<T> = new (...args: any[]) => T;
export type ReturnTypeOf<T extends AnyFunction | AnyFunction[]> =
T extends AnyFunction
? ReturnType<T>
: T extends AnyFunction[]
? // exclude `void` from intersection, see octokit/octokit.js#2115
UnionToIntersection<Exclude<ReturnType<T[number]>, void>>
: never;
/**
* @author https://stackoverflow.com/users/2887218/jcalz
* @see https://stackoverflow.com/a/50375286/10325032
*/
export type UnionToIntersection<Union> = (
Union extends any ? (argument: Union) => void : never
) extends (argument: infer Intersection) => void // tslint:disable-line: no-unused
? Intersection
: never;
type AnyFunction = (...args: any) => any;
export type OctokitPlugin = (
octokit: Octokit,
options: OctokitOptions,
) => { [key: string]: any } | void;
export type Hooks = {
request: {
Options: Required<OctokitTypes.EndpointDefaults>;
Result: OctokitTypes.OctokitResponse<any>;
Error: RequestError | Error;
};
[key: string]: {
Options: unknown;
Result: unknown;
Error: unknown;
};
};
export type StrictOmit<T, K extends keyof T> = {
[P in keyof T as P extends K ? never : P]: T[P];
} & {
[parameter: string]: unknown;
};