Skip to content

Flow allows unsound object type assertion #7360

@jfirebaugh

Description

@jfirebaugh

Try:

const o = { a: 1 };
o.a = 2;
(o: { a: 1 }); // Ok?!

I would have expected the assignment to have widened the deduced type for o to { a: 1|2 } or { a: number }, thus causing the type assertion to fail. Instead, it passes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Typing: soundnessNo false negatives (type checker claims that there is no error in the incorrect program)bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions