I am in need of a TypeScript generic type that has the capability to alter another type so that all scalar properties (such as strings, numbers, booleans, etc.) remain mandatory, while object types become optional.
For instance, given the User
type below, I would like name
and age
to be obligatory, but for address
to be made optional.
type User = {
name: string;
age: number;
address: {
street: string;
postcode: string;
};
};