/** Create a type that makes the given keys non-nullable, where the remaining keys are kept as is. If no keys are given, all keys will be made non-nullable. Use-case: You want to define a single model where the only thing that changes is whether or not some or all of the keys are non-nullable. @example ``` import type {SetNonNullable} from 'type-fest'; type Foo = { a: number | null; b: string | undefined; c?: boolean | null; }; // Note: In the following example, `c` can no longer be `null`, but it's still optional. type SomeNonNullable = SetNonNullable; //=> {a: null | number; b: string; c?: boolean} type AllNonNullable = SetNonNullable; //=> {a: number; b: string; c?: boolean} ``` @category Object */ export type SetNonNullable = { [Key in keyof BaseType]: Key extends Keys ? BaseType[Key] & {} // `& {}` is used instead of `NonNullable` because `NonNullable` doesn't get simplified. : BaseType[Key]; }; export {};