Error inferring tuple type arguments · Issue #16360 · microsoft/TypeScript (original) (raw)
TypeScript Version: nightly (2.4.0-dev.20170608)
Code
interface IPromise { then(onFulfill: (value: T) => IWhenable): IPromise; }
interface QPromise { then(onFulfill: (value: T) => IWhenable): IPromise; }
type IWhenable = IPromise | T;
declare function all<A, B>(promises: IWhenable<[IWhenable, IWhenable]>): IPromise<[A, B]>;
declare const prom1: QPromise<[QPromise, QPromise]>; const x1: IPromise<[string, number]> = all(prom1);
const prom2: IPromise<[IPromise, IPromise]> = prom1; const x2: IPromise<[string, number]> = all(prom2);
Expected behavior:
Since IPromise
and QPromise
have identical bodies, I would expect these to both work.
Actual behavior:
x1
fails, x2
succeeds.
src/a.ts(14,7): error TS2322: Type 'IPromise<[QPromise<string>, QPromise<number>]>' is not assignable to type 'IPromise<[string, number]>'.
Type '[QPromise<string>, QPromise<number>]' is not assignable to type '[string, number]'.
Type 'QPromise<string>' is not assignable to type 'string'.