ts-type-forge
    Preparing search index...

    Type Alias DeepPartial<T>

    DeepPartial: T extends Primitive
        ? T
        : T extends AnyFn
            ? T
            : T extends MutableMap<infer K, infer V>
                ? MutableMap<DeepPartial<K>, DeepPartial<V>>
                : T extends ReadonlyMap<infer K, infer V>
                    ? ReadonlyMap<DeepPartial<K>, DeepPartial<V>>
                    : T extends MutableSet<infer V>
                        ? MutableSet<DeepPartial<V>>
                        : T extends ReadonlySet<infer V>
                            ? ReadonlySet<DeepPartial<V>>
                            : T extends Record<string, any>
                            | readonly unknown[]
                                ? { [K in keyof T]?: DeepPartial<T[K]> }
                                : T

    Recursively applies the ? optional modifier to all properties of an UnknownRecord or array. Handles Map and Set types by applying DeepPartial to their keys/values. Primitives and functions are returned as is.

    Type Parameters

    • T

      The type to make deeply partial.

    A new type with all nested properties marked as optional.

    type Data = { a: number; b: { c: string[]; d: Map<number, boolean> } };
    type PartialData = DeepPartial<Data>;
    // Result: {
    // a?: number | undefined;
    // b?: {
    // c?: (string | undefined)[] | undefined;
    // d?: ReadonlyMap<number | undefined, boolean | undefined> | undefined;
    // } | undefined;
    // }