function extend<T, U>(first: T, second: U): T & U {
let result = <T & U>Object.assign({}, first, second);
return result;
}
class Person {
constructor(public name: string) { }
}
interface Loggable {
log(): void;
}
class ConsoleLogger implements Loggable {
log() {
console.log("11")
}
}
var jim = extend(new Person("Jim"), new ConsoleLogger());
console.log(jim);
var n = jim.name;
jim.log();
Why does this code give an error saying ‘jim.log is not a function’? I checked and jim only has a name property. Why isn’t the log function assigned to the jim object?