Type Magic: validation on type property

How to validate defs in object type properties?
export type validateSchema<
  def,
  schema,
  > = {
    [K in keyof schema]:
    K extends keyof def
      ? validateTypeRoot<def[K]>
      : validateTypeRoot<unknown>
  }

function test<const def>(
  def: validateSchema<def, { a: 1 }>,
) { }

test({
  a: 'str',
})

I did that three days ago but I forgot how
Was this page helpful?