mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
* Add shim function to typings Add shim function to typings for promise.prototype.finally so that it can be used in a TypeScript project. * Added shim test * Update code style. * Change return type to original promise. The finally block should return the type of the original promise, not whatever is passed in to the finally block.
15 lines
360 B
TypeScript
15 lines
360 B
TypeScript
import promiseFinally = require('promise.prototype.finally');
|
|
|
|
promiseFinally.shim();
|
|
|
|
var promise = new Promise<Boolean>((resolve, reject) => {
|
|
resolve(true);
|
|
});
|
|
|
|
promise.finally(() => {});
|
|
promise.then(() => {}, () => {}).finally(() => {});
|
|
promise.catch(() => {}).finally(() => {});
|
|
|
|
var allPromise = Promise.all([promise]);
|
|
allPromise.finally(() => {});
|