You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
declareletp: Promise<number>;declareletp2: Promise<number|string>;// TS infers pfinal to be Promise<number> incorrectly.// pfinal should be Promise<number|string>letpfinal=p.then(_=>p2);
Expected behavior:
Pfinal should be Promise<number|string>
Actual behavior:
Pfinal is inferred to be Promise<number>
Note any choice of Promise<T> and Promise<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 parameter TResult.
As far I can tell it is a consequence of the fix in #10524 (comment) and not a desired change.
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: