UNPKG

1.37 kBTypeScriptView Raw
1// Type definitions for request-promise-native 1.0
2// Project: https://github.com/request/request-promise-native
3// Definitions by: Gustavo Henke <https://github.com/gustavohenke>
4// Matt R. Wilson <https://github.com/mastermatt>
5// Cory Reed <https://github.com/swashcap>
6// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7// TypeScript Version: 2.3
8
9import request = require('request');
10import http = require('http');
11
12declare namespace requestPromise {
13 interface RequestPromise<T = any> extends request.Request, Promise<T> {
14 promise(): Promise<T>;
15 }
16
17 interface RequestPromiseOptions extends request.CoreOptions {
18 simple?: boolean | undefined;
19 transform?(body: any, response: request.Response, resolveWithFullResponse?: boolean): any;
20 transform2xxOnly?: boolean | undefined;
21 resolveWithFullResponse?: boolean | undefined;
22 }
23
24 type RequestPromiseAPI = request.RequestAPI<RequestPromise, RequestPromiseOptions, request.RequiredUriUrl>;
25 type FullResponse = request.Response;
26 type OptionsWithUri = request.UriOptions & RequestPromiseOptions;
27 type OptionsWithUrl = request.UrlOptions & RequestPromiseOptions;
28 type Options = OptionsWithUri | OptionsWithUrl;
29}
30
31declare const requestPromise: requestPromise.RequestPromiseAPI;
32export = requestPromise;