Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.d.ts incompatible with TypeScript lib definitions #352

Open
michens opened this issue Jun 26, 2019 · 0 comments
Open

.d.ts incompatible with TypeScript lib definitions #352

michens opened this issue Jun 26, 2019 · 0 comments

Comments

@michens
Copy link

michens commented Jun 26, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant