Skip to content

otplib API Documentation / @otplib/core / OptionalKeys

Type Alias: OptionalKeys<T, K>

OptionalKeys<T, K> = Omit<T, K> & Partial<Pick<T, K>>

Defined in: packages/core/src/utility-types.ts:87

Helper type to make all properties of T optional except those in K

Type Parameters

T

T

K

K extends keyof T

Example

ts
type Options = { a: string; b: number; c: boolean };
type OptionalBC = OptionalKeys<Options, 'b' | 'c'>;
// { a: string; b?: number; c?: boolean }

Released under the MIT License.