Skip to content

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

@geoffreytools

Description

@geoffreytools

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

Metadata

Metadata

Assignees

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