You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceOptional{foo?: string;}functionfoo(o: Optional): void{}foo('bar');// should throwfoo(1);// should throwfoo({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.
I couldn't find a relevant issue, but this does seem rather fundamental and against the principle of:
TypeScript Version:
1.8.7
Code
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.