TS2456

error TS2456: Type alias ‘MyValue‘ circularly references itself.

Broken Code ❌

1
2
3
4
5
type MyValue =
| number
| string
| Record<string, MyValue>
;

Fixed Code ✔️

When defining a recursive type, you have to use the object syntax:

1
2
3
4
5
type MyValue =
| number
| string
| { [key: string]: MyValue }
;