I want to write the following function
function override<T, U>(first: T, second: U): T {
let result = <T>{};
for (let id in first) {
result[id] = first[id];
}
for (let id in second) {
result[id] = second[id];
}
return result;
}
but make it typesafe. In my use case, both T
and U
are simple records types. I want T
to be required to have all the properties of U
. Is there a way to express this relation?