Type Alias IsOptionalKey<T, K, Then, Else>

IsOptionalKey<T, K, Then, Else>: K extends OptionalKeys<T>
    ? Then
    : Else

Validate if the key K in T is optional.

🎭 predicate

Type Parameters

  • T
  • K
  • Then = true
  • Else = false
IsOptionalKey({ a: 1 }, 'a') // false
IsOptionalKey({ a?: 1 }, 'a') // true