Supporting Promise.prototype.finally() in TypeScript (targeting ES5)

`Promise.prototype.finally()` is a stage 4 (finished) proposal for ES2018. TypeScript supports it via the declaration file `lib.esnext.promise.d.ts`:, importable via `--lib esnext.promise`.

I am using the `es6-promise` library to polyfill Promises, but have to interact with Promises returned from the standard library, eg. by `navigator.requestMediaKeySystemAccess()`. Thus, the global declaration of a Promise must match that of `es6-promise`. Otherwise, the following error will be returned when calling `Promise.resolve()` (where Promise is imported from `es6-promise`) from inside a Promise chain initiated by a core-library function:

Error:(12, 5) TS2719: Type 'Promise<T>' is not assignable to type 'Promise<T>'. Two different types with this name exist, but they are unrelated.
  Property 'finally' is missing in type 'Promise<T>'.

When I add `esnext.promise` to the `libs` section in my `tsconfig.json`, I receive a warning that it is not one of the allowed values. Additionally, `/Applications/` does not contain the expected `esnext.promise.d.ts` file.

How should I support `Promise.prototype.finally()`?


Please try 2018.1 EAP ( - it supports esnext.promise library


Thank you again Elena! That helps out a lot.

EDIT: This issue can be considered closed.