镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Error inferring tuple type arguments #16360

Description

TypeScript Version: nightly (2.4.0-dev.20170608)

Code

interface IPromise<T> {
    then<U>(onFulfill: (value: T) => IWhenable<U>): IPromise<U>;
}

interface QPromise<T> {
    then<U>(onFulfill: (value: T) => IWhenable<U>): IPromise<U>;
}

type IWhenable<T> = IPromise<T> | T;

declare function all<A, B>(promises: IWhenable<[IWhenable<A>, IWhenable<B>]>): IPromise<[A, B]>;

declare const prom1: QPromise<[QPromise<string>, QPromise<number>]>;
const x1: IPromise<[string, number]> = all(prom1);

const prom2: IPromise<[IPromise<string>, IPromise<number>]> = 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'.

Activity

mhegazy commented on Feb 12, 2018

@mhegazy
Contributor

Seems like a duplicate of #19194

added
DuplicateAn existing issue was already created
and removed
Needs InvestigationThis issue needs a team member to investigate its status.
on Feb 12, 2018
added
BugA bug in TypeScript
and removed
DuplicateAn existing issue was already created
on Feb 12, 2018

RyanCavanaugh commented on Oct 29, 2025

@RyanCavanaugh
Member

This can be written as

declare function all<A, B>(promises: IPromise<[A, B]>): IPromise<[Awaited<A>, Awaited<B>]>;

now

locked as resolved and limited conversation to collaborators on Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolution

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions