I've got a function (func) on a class (MyClass) with an optional parameter. The type of the optional parameter (MyInterface) has only optional properties.
I expected a compiler error when I call foo with a primitive like a number. But thats not the case. Why is it like that? And is there a way to tell the type system to mark that as an error?
interface MyInterface {
foo?: string
}
class MyClass {
func(b?: MyInterface) : void {}
}
let c = new MyClass();
c.func();
c.func({ foo: 'bar' });
c.func({ foo: 30 }); // compiler error: OK
c.func({});
c.func(60); // No compiler error: Not what I expect