flow
flow copied to clipboard
Type spread operator strips read-only properties
Flow version: 0.171.0
Expected behavior
In type A = {...ObjectType, +b} ...ObjectType should preserve read-only status of fields in ObjectType and should not affect read-only status of b.
Actual behavior
Flow behaves as if all fields in A are writable including b.
- Link to Try-Flow or Github repo: https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgBCAhgM4EC8YA3qmGANTEBcYAdgK4C2ARngE4AaOmB6tOvAcIC+AbnTZ8YACp5SGMFVr0AdHpLlh9BgGNx3PkNRz0UDmxMYAlnDZgocOAAoAHq1XqAJQ0Ij46xJpgAIwADLJgwMBgGAAWTqRgpClwHDAAJqIExG4C-HD8oTo8kVFR8vRhJjUATPGJyWkZWTn5YMQwpHCFfSX8ZRXStvaOLm48xPy+rAZ4wdpgYRFUsW1JqemZ2bkFfCNgpeWV1dt11qhAA
Thanks for catching this! @jbrown215 is this a known issue for type spreads?
Yes, this is known. This applies to every operation handled by object_kit.ml. Variance isn't tracked through there.