2. implement Required<T>
Share
- accepted / - tried
As the opposite of Partial<T>,
Required<T>
sets all properties of T
to required.
Please implement MyRequired<T>
by yourself.
// all properties are optionaltype Foo = { a?: string b?: number c?: boolean}const a: MyRequired<Foo> = {}// Errorconst b: MyRequired<Foo> = { a: 'BFE.dev'}// Errorconst c: MyRequired<Foo> = { b: 123}// Errorconst d: MyRequired<Foo> = { b: 123, c: true}// Errorconst e: MyRequired<Foo> = { a: 'BFE.dev', b: 123, c: true}// valid