mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
[@types/request-promise] Stop extending Promise. (#23087)
Both `@types/request-promise` and `@types/request-promise-native` were extending their particular `Promise` implementations, however, the actual libs don't extend these objects. All they do is add logic to the `Request.prototype.init` function and "expose" a few defined methods from theit `Promise` implementations. This came up while looking into the issue on #23004.
This commit is contained in:
5
types/request-promise-native/index.d.ts
vendored
5
types/request-promise-native/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
// Type definitions for request-promise-native 1.0
|
||||
// Project: https://github.com/request/request-promise-native
|
||||
// Definitions by: Gustavo Henke <https://github.com/gustavohenke>
|
||||
// Matt R. Wilson <https://github.com/mastermatt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -8,7 +9,9 @@ import request = require('request');
|
||||
import http = require('http');
|
||||
|
||||
declare namespace requestPromise {
|
||||
interface RequestPromise extends request.Request, Promise<any> {
|
||||
interface RequestPromise extends request.Request {
|
||||
then: Promise<any>["then"];
|
||||
catch: Promise<any>["catch"];
|
||||
promise(): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ rpn('http://google.com').then(() => { });
|
||||
rpn('http://google.com').then(console.dir);
|
||||
rpn('http://google.com').catch(console.error);
|
||||
rpn('http://google.com').then(console.dir, console.error);
|
||||
rpn('http://google.com').promise().then(console.dir);
|
||||
|
||||
rpn({ uri: 'http://google.com', resolveWithFullResponse: true }).then((response) => { });
|
||||
rpn({ uri: 'http://google.com', simple: false }).catch((reason) => { });
|
||||
|
||||
11
types/request-promise/index.d.ts
vendored
11
types/request-promise/index.d.ts
vendored
@@ -1,6 +1,9 @@
|
||||
// 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>
|
||||
// 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
|
||||
|
||||
@@ -10,7 +13,11 @@ import errors = require('./errors');
|
||||
import Promise = require('bluebird');
|
||||
|
||||
declare namespace requestPromise {
|
||||
interface RequestPromise extends request.Request, Promise<any> {
|
||||
interface RequestPromise extends request.Request {
|
||||
then: Promise<any>["then"];
|
||||
catch: Promise<any>["catch"];
|
||||
finally: Promise<any>["finally"];
|
||||
cancel: Promise<any>["cancel"];
|
||||
promise(): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ rp('http://google.com').finally(() => {});
|
||||
rp('http://google.com').then(console.dir);
|
||||
rp('http://google.com').catch(console.error);
|
||||
rp('http://google.com').then(console.dir, console.error);
|
||||
rp('http://google.com').cancel();
|
||||
rp('http://google.com').promise().then(console.dir);
|
||||
|
||||
// This works as well since additional methods are only used AFTER the FIRST call in the chain:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user