Fix hooks based on remarks from ikokostya

This commit is contained in:
Stijn Van Nieuwenhuyse
2018-10-29 20:08:39 +01:00
parent 618e005c76
commit c3aeace523
+6 -3
View File
@@ -97,8 +97,12 @@ declare namespace got {
type GotUrl = string | https.RequestOptions | Url | URL;
type Hook<T> = (options: T) => any;
type Hooks<T> = Record<'beforeRequest', Hook<T>[]>;
interface GotBodyOptions<E extends string | null> extends GotOptions<E> {
body?: string | Buffer | nodeStream.Readable;
hooks?: Hooks<GotBodyOptions<E>>;
}
interface GotJSONOptions extends GotOptions<string | null> {
@@ -106,16 +110,16 @@ declare namespace got {
body?: object;
form?: boolean;
json: true;
hooks?: Hooks<GotJSONOptions>;
}
interface GotFormOptions<E extends string | null> extends GotOptions<E> {
body?: {[key: string]: any};
form: true;
json?: boolean;
hooks?: Hooks<GotFormOptions<E>>;
}
type Hook = (options?: https.RequestOptions) => any;
interface GotOptions<E extends string | null> extends InternalRequestOptions {
baseUrl?: string;
cookieJar?: CookieJar;
@@ -128,7 +132,6 @@ declare namespace got {
useElectronNet?: boolean;
throwHttpErrors?: boolean;
agent?: http.Agent | boolean | AgentOptions;
hooks?: Record<'beforeRequest', Hook[]>;
cache?: Cache;
}