OptionGuards<T>
One guard per option of an all-optional object type, as optionsGuard takes them: each describes a PRESENT option, so it does not accept undefined. A required property of T takes never, so a type that is not all-optional does not compile.
Import:
import type { OptionGuards } from '@mnaoumov/typescript-lib/api-contract';Signature:
export type OptionGuards<T extends object>Signature:
type OptionGuards<T> = { readonly [TKey in keyof T]-?: Partial<Pick<T, TKey>> extends Pick<T, TKey> ? ExpectedTypeGuard<Exclude<T[TKey], undefined>> : never;}Type: { readonly [TKey in keyof T]-?: Partial<Pick<T, TKey>> extends Pick<T, TKey> ? ExpectedTypeGuard<Exclude<T[TKey], undefined>> : never; }
Links to this page: