Closed
Description
Suggestion to add types to lib.d.ts:
type RecursiveReadonly<T> = {
readonly [P in keyof T]: RecursiveReadonly<T[P]>;
};
type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};
Difference from Readonly and Partial
type ComplexType = { a: { b: { c: { d: number; } } } };
const x:Readonly<ComplexType> = {
a: { b: { c: { d: 1 } } }
};
const xx: RecursiveReadonly<ComplexType> = {
a: { b: { c: { d: 1 } } }
};
x.a.b.c.d = 3;
//xx.a.b.c.d = 3; // Error
const y:Partial<ComplexType> = {};
const yy: RecursivePartial<ComplexType> = {};
//y.a = {};// Error
yy.a = {}; // OK
Metadata
Metadata
Assignees
Labels
No labels