2. implement Required<T>

TypeScript
Is this helpful ?

  - 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 optional
type Foo = {
  a?: string
  b?: number
  c?: boolean
}


const a: MyRequired<Foo> = {}
// Error

const b: MyRequired<Foo> = {
  a: 'BFE.dev'
}
// Error

const c: MyRequired<Foo> = {
  b: 123
}
// Error

const d: MyRequired<Foo> = {
  b: 123,
  c: true
}
// Error

const e: MyRequired<Foo> = {
  a: 'BFE.dev',
  b: 123,
  c: true
}
// valid

Let's try to solve this problem within 5 minutes.

Discuss(11)