flow icon indicating copy to clipboard operation
flow copied to clipboard

Type spread operator strips read-only properties

Open ibukanov opened this issue 4 years ago • 2 comments

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

ibukanov avatar Feb 10 '22 21:02 ibukanov

Thanks for catching this! @jbrown215 is this a known issue for type spreads?

mvitousek avatar Feb 14 '22 17:02 mvitousek

Yes, this is known. This applies to every operation handled by object_kit.ml. Variance isn't tracked through there.

jbrown215 avatar Feb 14 '22 18:02 jbrown215