Type alias MaybeRequired<T, required>

MaybeRequired<T, required>: required extends true
    ? ExactRequired<T>
    : T

Type Parameters

  • T
  • required extends boolean

Description

Makes attributes on the type T required if required is true.

Example

MaybeRequired<{ a: string, b?: number }, true>
=> { a: string, b: number }

MaybeRequired<{ a: string, b?: number }, false>
=> { a: string, b?: number }