Spreading a generic value allows adding unexpected properties to it #8745
Labels
bug
Typing: soundness
No false negatives (type checker claims that there is no error in the incorrect program)
Typing: spread
Flow version: 0.159.0
Expected behavior
I'd expect Flow to error at
return {...val, bar: 1}
, since nothing in<T>
says that the object can have propertybar
.Flow correctly errors if I try to directly assign to the object with
val.bar = 1
Actual behavior
Flow doesn't show any errors, the code only fails at runtime. Flow allows both overwriting existing properties with incorrect types and adding completely new arbitrary properties to it (even though the type is exact).
Try-Flow
The text was updated successfully, but these errors were encountered: