Skip to content

Intersection disables disallowSuperfluousProperties all the way down #111

@lukas-valenta

Description

@lukas-valenta

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions