This is an expansion of this questions: typescript exclude optional fields from type
If I have a type like this:
type MyType = {
thingOne: { id: string; name?: string };
thingTwo?: { id: string; name?: string };
};
I want to be able to create a type that only has the required fields in the object, aswell as anything nested inside of it.
ie.
type MyRequireds = NonOptional<MyType>;
/*
{
thingOne: { id: string };
};
*/
is it possible?
TSPlayground link with shallow NonOptional TypeScripPlayground