You don’t get an error because you use a string to check if the property exists.
You will get the error this way:
interface Obj{
a: any;
}
const obj: Obj = { a: "test" };
if (obj.b) // this is not allowed
if ("b" in obj) // no error because you use string
If you want type checking to work for string properties you could add index signatures using this example