Reputation: 15
What's the difference between type Record<string, unkown> and type object?
Implement a generic DeepReadonly<T>
which make every parameter of an object - and its sub-objects recursively - readonly.
I wrote a type:
type DeepReadonly<T> = T extends object ? {readonly:[K in keyof T]:DeepReadonly<T[K]>}:T
but it's not correctly.
replaced this object
width Record<string,unkown>
, the 'DeepReadonly' worked well.
What's the difference?
Is that object
could be empty?But the Record<string,unkown>
must be {[key:string]:unkown}
?
Upvotes: 0
Views: 588
Reputation: 133
type object
refers to Reference Type
, it can be an array, function, or object literal.
Record<> only refers to object literal.
Upvotes: 1