I have a type like:
type Base = {
propA: number;
propB: string;
}
and need to convert it to:
type BaseWithNull = {
propA: number | null;
propB: string | null;
}
where all properties are potentially null. (NOT undefined where you could use "Partial")
is it possible to do this programmatically? I've experimented with mapped types like this:
type BaseWithNull = Base | {
[P in keyof BaseRemoteWeatherForecast]: null;
};
type BaseWithNull = Base & {
[P in keyof BaseRemoteWeatherForecast]: null;
};
but the first (union) results in a type where it's either an object with the Base type or an object with all null properties, while the second (intersection) results in all properties as "never" types since null and doesn't "overlap" with non-null types.