0 of 7 problems solved0%
5 of 7

Required Defaults

Required<T> makes all properties required. Pair it with Partial<T> for inputs that may omit fields and a function that fills in defaults. The result type communicates that nothing is missing after defaulting.

// Example: fill defaults so the return type is fully required
function withDefaults(partial: Partial<Cfg>): Required<Cfg>;

Your Task

Fill missing config fields and return a fully required config.

  • Define type Config = { retries: number; timeout: number; verbose: boolean }.
  • Implement function fillDefaults(cfg: Partial<Config>): Required<Config>.
  • Use defaults { retries: 3, timeout: 1000, verbose: false } for any missing field.
  • Return a new object without mutating the input.