For v4.0.0-rc.9, Record({ counter: 0 }) corresponds to type RecordOf<{ counter: number }>,
It would be great if it corresponded to type RecordOf<$ReadOnly<{counter: number }>>.
Would a PR making this change to the Flow types be welcome?
Here's an example of a change to immutable.js.flow:
// The type of runtime Record instances.
- type RecordOf<Values: Object> = RecordInstance<Values> & Values;
+ type RecordOf<Values: Object> = RecordInstance<Values> & $ReadOnly<Values>;
Great idea - in fact everywhere Values is referenced (sometimes as T) this should be the correct behavior.
Should we also use $Exact<> ?
The semantics are as follows:
T: { a: number, b: string }
foo: $Exact<T> = { a: 3 } // error
bar: $Exact<T> = { a: 3, b: 'hello' } // fine
I'm not sure that's necessary since Exact and & do not always interact together the way you might expect, but if you find that it improves type correctness I'm open to looking at PRs
Most helpful comment
Great idea - in fact everywhere Values is referenced (sometimes as T) this should be the correct behavior.