Closed
Description
I couldn't find a relevant issue, but this does seem rather fundamental and against the principle of:
- Statically identify constructs that are likely to be errors.
TypeScript Version:
1.8.7
interface Optional {
foo?: string;
}
function foo(o: Optional): void {}
foo('bar'); // should throw
foo(1); // should throw
foo({ bar: 'baz' }); // should (and does) throw
Expected behavior:
Expected behaviour is that you should be able to type guard against other non-objects and only accept Objects with no properties or declared properties.
Actual behavior:
Passing anything other than an object literal that contains extra properties is acceptable.