mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 16:27:06 +00:00
* [@types/request] Fill out Request and Response. This hold much more true to the actual lib where a `Request` and `Response` reference each other and the `Request` has most of the provided options merged onto it, plus other stuff. Makes use of the newly added `@types/caseless` to DRY up some of the header work. Updated version reference from 2.0 to 2.47 to cover both the addition of `caseless` and the removal of `getAgent` from the lib. I have a project that uses `request-promise-native`, these changes work in my testing and having the `Response` object typed allowed me to remove all my declaration merging files from the `request` namespace. * [@types/request] Update promise sub-libs. Update `request-promise` and `request-promise-native` to use new `Response` interface.
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
// Type definitions for request-promise 4.1
|
|
// Project: https://github.com/request/request-promise
|
|
// Definitions by: Christopher Glantschnig <https://github.com/cglantschnig>
|
|
// Joe Skeen <https://github.com/joeskeen>
|
|
// Aya Morisawa <https://github.com/AyaMorisawa>
|
|
// Matt R. Wilson <https://github.com/mastermatt>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
// TypeScript Version: 2.3
|
|
|
|
import request = require('request');
|
|
import http = require('http');
|
|
import errors = require('./errors');
|
|
import Promise = require('bluebird');
|
|
|
|
declare namespace requestPromise {
|
|
interface RequestPromise extends request.Request {
|
|
then: Promise<any>["then"];
|
|
catch: Promise<any>["catch"];
|
|
finally: Promise<any>["finally"];
|
|
cancel: Promise<any>["cancel"];
|
|
promise(): Promise<any>;
|
|
}
|
|
|
|
interface RequestPromiseOptions extends request.CoreOptions {
|
|
simple?: boolean;
|
|
transform?(body: any, response: request.Response, resolveWithFullResponse?: boolean): any;
|
|
transform2xxOnly?: boolean;
|
|
resolveWithFullResponse?: boolean;
|
|
}
|
|
|
|
type OptionsWithUri = request.UriOptions & RequestPromiseOptions;
|
|
type OptionsWithUrl = request.UrlOptions & RequestPromiseOptions;
|
|
type Options = OptionsWithUri | OptionsWithUrl;
|
|
}
|
|
|
|
declare var requestPromise: request.RequestAPI<requestPromise.RequestPromise, requestPromise.RequestPromiseOptions, request.RequiredUriUrl>;
|
|
export = requestPromise;
|