-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
With disallowSuperfluousProperties on, the following code results in wrong typecheck:
type Foo = {
quux: string;
};
type BarIntersection = {
foo: Foo;
} & {
bar: string;
};
type BarNotIntersection = {
foo: Foo;
bar: string;
};
const document = {
bar: 'bar',
foo: {
quux: 'quux',
super: 'fluous'
}
};The super: 'fluous' property does not get caught with is<BarIntersection>, but is<Foo> and is<BarNotIntersection> both catch it. This is because typescript-is disables disallowSuperflousProperties when encountering an intersection (and for a good reason), but never restores it. I have written a test case and a quick-and-dirty fix, I will post a PR soon.
NOTE: This is just minimal reproduction, obviously the intersection is not needed in this example.
Metadata
Metadata
Assignees
Labels
No labels