Merge pull request #28161 from d-ph/28081/bluebird-global-loses-promise-generic-type-on-instance-methods

[bluebird-global] Change how instance methods are pulled from Bluebird.
This commit is contained in:
Benjamin Lichtman
2018-08-16 13:39:56 -07:00
committed by GitHub
2 changed files with 50 additions and 46 deletions
@@ -40,3 +40,7 @@ function testPromiseRejection() {
return value.toUpperCase();
});
}
function testGithubTicket28081Regression() {
Promise.resolve([3]).map((n: number) => true);
}
+46 -46
View File
@@ -67,52 +67,52 @@ declare global {
* Patch all instance method
*/
interface Promise<T> {
all: typeof Bluebird.prototype.all;
any: typeof Bluebird.prototype.any;
asCallback: typeof Bluebird.prototype.asCallback;
bind: typeof Bluebird.prototype.bind;
call: typeof Bluebird.prototype.call;
cancel: typeof Bluebird.prototype.cancel;
// catch: typeof Bluebird.prototype.catch;
caught: typeof Bluebird.prototype.caught;
delay: typeof Bluebird.prototype.delay;
disposer: typeof Bluebird.prototype.disposer;
done: typeof Bluebird.prototype.done;
each: typeof Bluebird.prototype.each;
error: typeof Bluebird.prototype.error;
filter: typeof Bluebird.prototype.filter;
// finally: typeof Bluebird.prototype.finally;
get: typeof Bluebird.prototype.get;
isCancelled: typeof Bluebird.prototype.isCancelled;
isFulfilled: typeof Bluebird.prototype.isFulfilled;
isPending: typeof Bluebird.prototype.isPending;
isRejected: typeof Bluebird.prototype.isRejected;
isResolved: typeof Bluebird.prototype.isResolved;
lastly: typeof Bluebird.prototype.lastly;
map: typeof Bluebird.prototype.map;
mapSeries: typeof Bluebird.prototype.mapSeries;
nodeify: typeof Bluebird.prototype.nodeify;
props: typeof Bluebird.prototype.props;
race: typeof Bluebird.prototype.race;
reason: typeof Bluebird.prototype.reason;
reduce: typeof Bluebird.prototype.reduce;
reflect: typeof Bluebird.prototype.reflect;
return: typeof Bluebird.prototype.return;
some: typeof Bluebird.prototype.some;
spread: typeof Bluebird.prototype.spread;
suppressUnhandledRejections: typeof Bluebird.prototype.suppressUnhandledRejections;
tap: typeof Bluebird.prototype.tap;
tapCatch: typeof Bluebird.prototype.tapCatch;
// then: typeof Bluebird.prototype.then;
thenReturn: typeof Bluebird.prototype.thenReturn;
thenThrow: typeof Bluebird.prototype.thenThrow;
catchReturn: typeof Bluebird.prototype.catchReturn;
catchThrow: typeof Bluebird.prototype.catchThrow;
throw: typeof Bluebird.prototype.throw;
timeout: typeof Bluebird.prototype.timeout;
toJSON: typeof Bluebird.prototype.toJSON;
toString: typeof Bluebird.prototype.toString;
value: typeof Bluebird.prototype.value;
all: Bluebird<T>["all"];
any: Bluebird<T>["any"];
asCallback: Bluebird<T>["asCallback"];
bind: Bluebird<T>["bind"];
call: Bluebird<T>["call"];
cancel: Bluebird<T>["cancel"];
// catch: Bluebird<T>["catch"];
caught: Bluebird<T>["caught"];
delay: Bluebird<T>["delay"];
disposer: Bluebird<T>["disposer"];
done: Bluebird<T>["done"];
each: Bluebird<T>["each"];
error: Bluebird<T>["error"];
filter: Bluebird<T>["filter"];
// finally: Bluebird<T>["finally"];
get: Bluebird<T>["get"];
isCancelled: Bluebird<T>["isCancelled"];
isFulfilled: Bluebird<T>["isFulfilled"];
isPending: Bluebird<T>["isPending"];
isRejected: Bluebird<T>["isRejected"];
isResolved: Bluebird<T>["isResolved"];
lastly: Bluebird<T>["lastly"];
map: Bluebird<T>["map"];
mapSeries: Bluebird<T>["mapSeries"];
nodeify: Bluebird<T>["nodeify"];
props: Bluebird<T>["props"];
race: Bluebird<T>["race"];
reason: Bluebird<T>["reason"];
reduce: Bluebird<T>["reduce"];
reflect: Bluebird<T>["reflect"];
return: Bluebird<T>["return"];
some: Bluebird<T>["some"];
spread: Bluebird<T>["spread"];
suppressUnhandledRejections: Bluebird<T>["suppressUnhandledRejections"];
tap: Bluebird<T>["tap"];
tapCatch: Bluebird<T>["tapCatch"];
// then: Bluebird<T>["then"];
thenReturn: Bluebird<T>["thenReturn"];
thenThrow: Bluebird<T>["thenThrow"];
catchReturn: Bluebird<T>["catchReturn"];
catchThrow: Bluebird<T>["catchThrow"];
throw: Bluebird<T>["throw"];
timeout: Bluebird<T>["timeout"];
toJSON: Bluebird<T>["toJSON"];
toString: Bluebird<T>["toString"];
value: Bluebird<T>["value"];
/*
* Copy&paste ::then and ::catch from lib.es2015.promise.d.ts, because Bluebird's typings are not