RequireSome type from a similar question, we are looking to create a new type that not only requires certain fields but also removes null and undefined values. This distinguishes it from the original RequireSome type.
We might consider naming this new type NonNullable or something similar. The purpose of this type is to define which fields within a type should not be undefined or null, and then return their types without these unwanted values.
type Question = {
id: string;
answer?: string | null;
thirdProp?: number | null;
fourthProp?: number | null;
}
// using NonNullable<Question, 'answer' | 'thirdProp'> would result in
/*
type Question = {
id: string; // no changes
answer: string; // changed
thirdProp: number; // changed
fourthProp?: number | null; // no changes
}
*/