Charlie A
Charlie A

Reputation: 496

Why are TS circular references allowed for object type defs

Why is this type valid:

export type CircularObj = { [key: string]: CircularObj }

but this type is not:

export type CircularRecord = Record<string, CircularRecord>

I am getting the error TS2456: Type alias 'CircularRecord' circularly references itself. for CircularRecord, but not for CircularObj, and I am wondering why?

I am using typescript version 4.1.6

Upvotes: 1

Views: 81

Answers (0)

Related Questions