-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
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) throwExpected 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript