Readonly
introduction#
Implement the built-in Readonly<T> generic without using it.
Constructs a type with all properties of T set to readonly, meaning the properties of the constructed type cannot be reassigned.
For example
ts
View on GitHubts
start point#
tsTry/* _____________ Your Code Here _____________ */typeMyReadonly <T > = any;Â/* _____________ Test Cases _____________ */typeType 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.cases = [Expect <Equal <MyReadonly <Todo1 >,Readonly <Todo1 >>>];ÂinterfaceTodo1 {title : string;description : string;completed : boolean;meta : {author : string;};}
take the challengetsTry/* _____________ Your Code Here _____________ */typeMyReadonly <T > = any;Â/* _____________ Test Cases _____________ */typeType 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.cases = [Expect <Equal <MyReadonly <Todo1 >,Readonly <Todo1 >>>];ÂinterfaceTodo1 {title : string;description : string;completed : boolean;meta : {author : string;};}