When working with TypeScript, you may have come across the Required
type which transforms object properties into defined ones.
For instance:
interface Person {
name?: string;
age?: number;
}
Using Required<Person>
will result in:
interface Person {
name: string;
age: number;
}
Now, my inquiry is whether there exists a similar type that can convert nullable properties to non-nullable ones.
Consider the following scenario:
interface Person {
name: string | null;
age: number | null;
}
Desired outcome:
interface Person {
name: string;
age: number;
}
Appreciate any insights!