You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spreading a generic value allows adding unexpected properties to it #8745
I'd expect Flow to error at return {...val, bar: 1}, since nothing in <T> says that the object can have property bar.
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).
Thanks for the report! We've had some improvements to the soundness of the interaction of generics and spreads to the to-do list for a while, it looks like this hits on one of the ways that they interact in an unsound way.
Activity
mvitousek commentedon Sep 20, 2021
Thanks for the report! We've had some improvements to the soundness of the interaction of generics and spreads to the to-do list for a while, it looks like this hits on one of the ways that they interact in an unsound way.