Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 608 Bytes

File metadata and controls

31 lines (21 loc) · 608 Bytes

Home > types-kit > OptionalKeys

OptionalKeys type

Get optional property keys of T.

Signature:

export type OptionalKeys<T> = {
  [K in keyof T]-?: {} extends Pick<T, K> ? K : never
}[Keys<T>]

References: Keys

Example

interface Props {
    a?: number
    readonly b: number
    c?: number
  }

  // Expect: 'a' | 'c'
  type PropKeys = OptionalKeys<Props>