I am working on a TypeScript project where I need to transform a type with optional properties into a type where the optional
properties are replaced with union types that include null
. For example, I would like to transform this type A
:
interface A {
a?: string;
b?: { c?: number };
d: boolean;
}
into this type B
:
interface B {
a: string | null;
b: { c: number | null } | null;
d: boolean;
}
Furthermore, I would like this utility type to also support property access, such that the following code:
type C = DeepUndefinedToNull<A["a"]>
returns a type C
equivalent to string | null
.
Despite extensive efforts and even assistance from OpenAI's GPT model, I've been unable to create a utility type that achieves this. I believe this could be a valuable addition to type-fest
and would be useful for many TypeScript developers who need to handle optional properties in this way.
Would you please consider adding such a utility type to type-fest
? Thank you for your time and consideration.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too