.d.ts 与 TypeScript 库定义不兼容

作者: michens创建于 2019年6月26日更新于 2019年6月26日

Sandbox 使用 "lib": ["es5", "es2015.promise"]error 无法编译,出现以下消息: Property 'finally' is missing in type 'Promise<void>' but required in type 'Promise<void>'. Sandbox 使用 "lib": ["es5", "es2015.promise", "es2018.promise"]error 无法编译,出现以下消息: Type 'Promise<void>' is not assignable to type 'import("/sandbox/node_modules/es6-promise/es6-promise").Promise<void>'. Types of property 'catch' are incompatible. Type '<TResult = never>(onrejected?: (reason: any) => TResult | PromiseLike<TResult>) => Promise<void | TResult>' is not assignable to type '<U>(onRejected?: (error: any) => U | Thenable<U>) => Promise<U>'. Type 'Promise<void | U>' is not assignable to type 'Promise<U>'. Types of property 'then' are incompatible. Type '<TResult1 = void | U, TResult2 = never>(onfulfilled?: (value: void | U) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>' is not assignable to type '{ <U>(onFulfilled?: (value: U) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Promise<U>; <U>(onFulfilled?: (value: U) => U | Thenable<U>, onRejected?: (error: any) => void): Promise<...>; }'. Types of parameters 'onfulfilled' and 'onFulfilled' are incompatible. Types of parameters 'value' and 'value' are incompatible. Type 'void | U' is not assignable to type 'U'. Type 'void' is not assignable to type 'U'. Sandbox 使用 es6 (或更高版本) 代替上面的 es5error 会出现相同的消息,但还会为 error2 添加另一个失败,消息为: Property '[Symbol.toStringTag]' is missing in type 'Promise<void>' but required in type 'Promise<void>'. error2 的消息在 #300 中提出,但未得到修复。

内容来源: stefanpenner/es6-promise