Skip to content

Circularity error in intersection of object with index signature #38672

Closed
@ahejlsberg

Description

@ahejlsberg

TypeScript Version: 4.0.0-dev

Code

type Foo1 = { x: string } & { [x: number]: Foo1 };    // Circularity error
type Foo2 = { x: string } & { [K in number]: Foo2 };  // No error

Expected behavior:

No errors.

Actual behavior:

Error: Type alias 'Foo1' circularly references itself.

Playground Link:

https://www.typescriptlang.org/play/index.html?ssl=1&ssc=1&pln=3&pc=1#code/C4TwDgpgBAYg9nAjFAvFA3lAHgLigZ2ACcBLAOwHMoBfKAMgygG1coyBXAWwCMIiBdPPCQ0A3FAlQA9FKgBhEkQDG7ADYBDUqCh8icIgChQkWAgBMqRq0KlKNeoyYBpKOTZdeAoebESZUADk4HSI9QyA

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions