Type alias NonRequiredKeys<T>

NonRequiredKeys<T>: Exclude<Keys<T>, RequiredKeys<T>>

Why not call it OptionalKeys? Optional<T> in this library represents a type T that can be either T or null. So creating OptionalKeys type would entail removing any type that can be null, which is not the intention here.

NonRequiredKeys<T> simply removes non required keys, as in any property of an object that is marked with ? operator

Type Parameters

  • T

Example

type T = NonRequiredKeys<{ a: number; b?: string }> // Result:  'b'