Type alias DeepRequired<T>

DeepRequired<T>: T extends UnknownFunction
    ? T
    : {
        [K in Keys<T>]-?: IfExtends<T[K], unknown, DeepRequired<T[K]>, T[K]>
    }

Make all object properties required

Type Parameters

  • T

Example

type Expected = {
a: () => 1;
x: string;
s: {
q: Nullable;
s: {
i: {
x: {
o: Maybe<Primitive>;
n: Falsy;
};
e: 'foo';
};
};
};
};

type Actual = {
a?: () => 1;
x?: string;
s?: {
q?: Nullable;
s?: {
i?: {
x?: {
o?: Maybe<Primitive>;
n?: Falsy;
};
e?: 'foo';
};
};
};
};
type T = DeepRequired<Actual>; // Result: Expected