Skip to content

Can no longer write deep predicates in conditional typesΒ #52271

Description

Bug Report

πŸ”Ž Search Terms

conditional types, generics, deep, predicate

πŸ•— Version & Regression Information

This changed between versions 4.8.4 and 4.9.4

⏯ Playground Link

Playground link with the code bellow

πŸ’» Code

type Foo<A,B> = [A, B] extends unknown[][] ? Bar<[A, B]> : 'else'
//                                               ~~~~~~
// Type '[A, B]' does not satisfy the constraint 'unknown[][]'.

type Bar<T extends unknown[][]> = T

This is not limited to tuples

type Foo<A> = Set<A> extends Set<unknown[]> ? Bar<Set<A>> : 'else'
//                                                ~~~~~
// Type 'Set<A>' does not satisfy the constraint 'Set<unknown[]>'.

type Bar<T extends Set<unknown[]>> = T

πŸ™ Actual behavior

There is a type error that literally contradicts the predicate of the conditional

πŸ™‚ Expected behavior

It should compile with no error

Activity

  1. jakebailey commented on Jan 20, 2023

    @jakebailey
    Member

    Both of these compile in nightly (soon to be beta) as of #51621, so this looks to be a duplicate of #51614.

    (Flip your playground to nightly to see.)

  2. geoffreytools commented on Jan 20, 2023

    @geoffreytools
    Author

    It's great that it is fixed but it must have been in a different PR, or maybe it was an unintentional side-effect, because these 2 issues are not related to me: the outcome of the conditional cannot be known here.

    I feel that a test case should be added for this scenario if it hasn't been already.

  3. jakebailey commented on Jan 20, 2023

    @jakebailey
    Member

    That PR definitely fixed it; I bisected to confirm before replying.

  4. jakebailey commented on Jan 20, 2023

    @jakebailey
    Member

    I've also checked and it was #50397 which regressed this.

  5. jakebailey commented on Jan 20, 2023

    @jakebailey
    Member

    Sent #52333 with a test.

  6. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions