I have encountered an issue when trying to enable --strictNullChecks in my code.
After enabling --strictNullChecks, I am getting the error message:
The property 'hasOwnProperty' is missing from type 'T1'.
The property 'hasOwnProperty' is missing from type 'T2'.
function extend<T1, T2>(arg1: T1, arg2: T2): T1 & T2 {
const result: Partial<T1 & T2> = {};
for (const prop in arg1) {
if (arg1.hasOwnProperty(prop)) { // encountering error with --strictNullChecks
(result as T1)[prop] = arg1[prop];
}
}
for (const prop in arg2) {
if (arg2.hasOwnProperty(prop)) { // encountering error with --strictNullChecks
(result as T2)[prop] = arg2[prop];
}
}
return result as T1 & T2;
}