There is the Utility type NonNullable
which will remove undefined
and null
values from a union type. But I was wondering if there was a way to remove optional fields from a type.
Basically if I have a type like this:
type MyType = {
thingOne: number,
thingTwo?: number
};
I want to be able to create a type out of the required fields only
type MyRequireds = NonOptional<MyType>;
// which is a type only containing "thingOne"
Is there some utility class that would satisfy the made up "NonOptional" utility class?