Type alias DeepToPrimitive<T>

DeepToPrimitive<T>: {
    [K in Keys<T>]: T[K] extends object
        ? DeepToPrimitive<T[K]>
        : _FindPrimitive<T[K]>
}

Recursively transforms an object type T into a type where all properties are replaced with their corresponding primitive types.

Type Parameters

  • T

    The object type to transform.

Returns

A new object type with primitive types.

Example

type Actual = {
a: 'a';
b: 85;
c: true;
d: {
e: 'xxxxxxxxxxx';
f: 'eeeeeeeeeeeeeeeeee';
g: {
h: 1000000000000000;
i: undefined;
j: null;
};
};
};

type Expected = {
a: string;
b: number;
c: boolean;
d: {
e: string;
f: string;
g: {
h: number;
i: undefined;
j: null;
};
};
};

type Result = DeepToPrimitive<Actual>; // Result: Expected