Skip to content

Constraints cannot be proven in mapped types combination #13039

Closed
@Igorbek

Description

@Igorbek

TypeScript Version: 2.1.4 / nightly (2.2.0-dev.20161219)

Code

type A<T> = () => T;
type B<T, C extends A<T>> = C;
type As<Ts> = {
    [P in keyof Ts]: A<Ts[P]>;
};

type Failing<Ts, Cs extends As<Ts>> = {
    [P in keyof Ts]: B<Ts[P], Cs[P]>;
//                            ~~~~~ Type 'Cs[P]' does not satisfy the constraint 'A<Ts[P]>'.
};

Expected behavior:

No errors, the constraint has been proven

Actual behavior:

Error in Failing type at B<Ts[P], Cs[P]>: Type 'Cs[P]' does not satisfy the constraint 'A<Ts[P]>'.

Note

If I change A<T> to be just T (type A<T> = T;), all compiles just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions