-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Promise type inference issue with supertypes #13420
Labels
Duplicate
An existing issue was already created
Comments
This is related to #13015, #13008 and in particular this comment from the latter #13008 (comment) then(
onfulfilled?: ((value: T) => T | PromiseLike<T>) | undefined | null,
onrejected?: ((reason: any) => T | PromiseLike<T>) | undefined | null
): Promise<T>; is not only redundant but is causing this specific bug. |
Agree, thanks for reference, closing in favor of #10977 as the canonical bug for this. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
TypeScript Version: 2.1.4
Code
Expected behavior:
Pfinal should be
Promise<number|string>
Actual behavior:
Pfinal is inferred to be
Promise<number>
Note any choice of
Promise<T>
andPromise<S>
where S is a supertype of T will trigger this error.This happens because then function overload
then(onfulfilled?: ((value: T) => T | PromiseLike<T>) | undefined | null, ...): Promise<T>;
is matching before the one with the free type parameterTResult
.As far I can tell it is a consequence of the fix in #10524 (comment) and not a desired change.
//cc @calebegg
The text was updated successfully, but these errors were encountered: