Skip to content

Unexpected circular constraint error (regression) #30920

@falsandtru

Description

@falsandtru

TypeScript Version: master

Search Terms:

Code

type StrictExtract<T, U> = T extends U ? U extends T ? T : never : never;
type StrictExclude<T, U> = T extends StrictExtract<T, U> ? never : T;
type A<T> = { [Q in { [P in keyof T]: P; }[keyof T]]: T[Q]; };
type B<T, V> = A<{ [Q in keyof T]: StrictExclude<B<T[Q], V>, {}>; }>;

Expected behavior:

pass

Actual behavior:

$ node built/local/tsc.js --noEmit index.ts
index.ts:3:21 - error TS2313: Type parameter 'Q' has a circular constraint.

3 type A<T> = { [Q in { [P in keyof T]: P; }[keyof T]]: T[Q]; };
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  index.ts:4:36
    4 type B<T, V> = A<{ [Q in keyof T]: StrictExclude<B<T[Q], V>, {}>; }>;
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Circularity originates in type at this location.


Found 1 error.

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

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