Open
Description
The minimal example:
//@flow
import {Map} from 'immutable';
type Key$Lower = 'application' | 'status' | 'hostname' | 'timestamp';
type Map$Lower = Map<
Key$Lower
, number | string
>;
type Key$Upper = 'updates';
type Map$Upper = Map<Key$Upper, Map$Lower>;
function update_ts(timestamp: number): number
{
console.log('timestamp=%o', timestamp);
return timestamp;
}
function foo(current: Map$Upper)
{
let next = current.updateIn(
['updates', 'timestamp']
, 0
, t => update_ts(t)
);
console.log('next=%o', next);
}
Cause the following error:
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/foo.js:25:32
Cannot call update_ts with t bound to timestamp because string [1] is incompatible with number [2].
src/foo.js
[2] 15│ function update_ts(timestamp: number): number
:
22│ let next = current.updateIn(
23│ ['updates', 'timestamp']
24│ , 0
25│ , t => update_ts(t)
26│ );
27│ console.log('next=%o', next);
28│ }
node_modules/immutable/dist/immutable.js.flow
[1] 695│ updateIn<NSV, K2: $KeyOf<V>, S: $ValOf<V, K2>>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<V, K2> | NSV) => S): this;
If that is not a bug, I would really appreciate an explanation of this behavior %)