.d.ts incompatible with TypeScript lib definitions
michens opened this issue · 0 comments
import { Promise as Promise6 } from "es6-promise";
export const error: Promise6<void> = Promise.resolve();
export const error2: Promise<void> = Promise6.resolve();
Sandbox
With "lib": ["es5", "es2015.promise"]
, error
fails to compile with the message:
Property 'finally' is missing in type 'Promise<void>' but required in type 'Promise<void>'.
Sandbox
With "lib": ["es5", "es2015.promise", "es2018.promise"]
, error
fails to compile with the message:
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
Using es6
(or newer) in place of es5
above gives the same message for error
, but adds another failure for error2
with the message:
Property '[Symbol.toStringTag]' is missing in type 'Promise<void>' but required in type 'Promise<void>'
The error2
message was brought up in #300, which was closed without a fix.
It's really frustrating working with libraries that use es6-promise
and export the type in their signatures, because you need to wrap the promises or cast away all type safety.
Are there any TypeScript lib configurations that are compatible with this library's typings, or are there any plans to update the definitions to be compatible?