import type {BuiltIns, HasMultipleCallSignatures} from './internal/index.d.ts'; import type {IsNever} from './is-never.d.ts'; /** Create a type from another type with all keys and nested keys set to required. Use-cases: - Creating optional configuration interfaces where the underlying implementation still requires all options to be fully specified. - Modeling the resulting type after a deep merge with a set of defaults. @example ``` import type {RequiredDeep} from 'type-fest'; type Settings = { textEditor?: { fontSize?: number; fontColor?: string; fontWeight?: number | undefined; }; autocomplete?: boolean; autosave?: boolean | undefined; }; type RequiredSettings = RequiredDeep; //=> { // textEditor: { // fontSize: number; // fontColor: string; // fontWeight: number | undefined; // }; // autocomplete: boolean; // autosave: boolean | undefined; // } ``` Note that types containing overloaded functions are not made deeply required due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732). @category Utilities @category Object @category Array @category Set @category Map */ export type RequiredDeep = T extends BuiltIns ? T : T extends Map ? Map, RequiredDeep> : T extends Set ? Set> : T extends ReadonlyMap ? ReadonlyMap, RequiredDeep> : T extends ReadonlySet ? ReadonlySet> : T extends WeakMap ? WeakMap, RequiredDeep> : T extends WeakSet ? WeakSet> : T extends Promise ? Promise> : T extends (...arguments_: any[]) => unknown ? IsNever extends true ? T : HasMultipleCallSignatures extends true ? T : ((...arguments_: Parameters) => ReturnType) & RequiredObjectDeep : T extends object ? RequiredObjectDeep : unknown; type RequiredObjectDeep = { [KeyType in keyof ObjectType]-?: RequiredDeep }; export {};