As I review my code, I realize that I have defined an interface as follows:
interface User {
name: string,
age: number
}
I also have a function written like this:
function test(user: User): void {
}
In addition, I have created an empty object using the same interface:
const user1 = <User>{};
test(user1);
Surprisingly, my code is compiling even though the empty object does not contain the keys specified in the interface. This leaves me wondering how I can enforce compilation errors if the object is missing the required interface keys.