Type Alias RecursivePartial<T>

RecursivePartial<T>: {
    [P in keyof T]?: T[P] extends (infer U)[]
        ? RecursivePartial<U>[] | undefined
        : T[P] extends infer F extends AnyFunction
            ? [keyof T[P]] extends [undefined]
                ? T[P] | undefined
                : ExtractFunction<F> & RecursivePartial<Properties<T[P]>>
            : T[P] extends AnyRecord
                ? RecursivePartial<T[P]> | undefined
                : T[P] | undefined
}

Creates a recursive partial type of type T.

Type Parameters

  • T
interface Foo {
bar: number;
baz: {
qux: string
}
}

type PartialFoo = RecursivePartial<Foo>
// {
// bar?: number | undefined;
// baz?: {
// qux?: string | undefined
// } | undefined
// }