May be related:
> https://github.com/Microsoft/TypeScript/issues/280
> https://github.com/Microsoft/ TypeScript/issues/7015
> https://github.com/Microsoft/TypeScript/issues/6722
> Declaration merging with ES6 style modules
Unfortunately typings on DefinitelyTyped does not currently support the gasket function so until this is supported, I suggest you add these typewriters yourself.< /p>
declare interface Promise{
finally(onFinally?: () => U | Promise): Promise;< br />}
declare module'promise.prototype.finally' {
export function shim(): void;
}
These types are now available . During installation
npm install --save-dev @types/promise.prototype.finally
In TypeScript code, during application boot, You can call
import {shim} from'promise.prototype.finally';
shim();
This will finally block Added to the Promise prototype, allowing you to use finally as needed.
This ES6 Promise compatible final implementation named promise.prototype.finally is used in the Node application. I want to convert it to TypeScript, but I cannot find the available types for this package on DefinitelyTyped. In these cases I wrote me I need the definition of a subset of functions for my own improvisation type, but in this case, it is a library that modifies the prototype of the Promise object, and I haven’t encountered any traditional way of expressing it in TypeScript. Any ideas?
May be related:
> https://github.com/Microsoft/TypeScript/issues/280
> https://github.com/Microsoft/ TypeScript/issues/7015
> https://github.com/Microsoft/TypeScript/issues/6722
> Declaration merging with ES6 style modules
< p>Although Slava’s answer is correct, it only involves the input of the finally block. To actually incorporate the filler into the code so that you can write p.finally(()=> (…)), you need to call the filler
Unfortunately typings on DefinitelyTyped currently does not support the shim function so until this is supported, I suggest you add these typewriters yourself.
declare interface Promise{
finally(onFinally?: () => U | Promise): Promise;
}
declare module'promise.prototype.finally' {
export function shim(): void;
}
These types are now available. When installing
p>
npm install --save-dev @types/promise.prototype.finally
In TypeScript code, during application boot, you can call
p>
import {shim} from'promise.prototype.finally';
shim();
This will add the finally block to the Promise prototype, allowing you to use finally as needed .