656f69c1c8/ramda_v0.x.x/flow_>=v0.49.x)The following code
function pluckIds<V, T: Array<{ [key: string]: V }>>(items: T) {
return R.pluck('id', items)
}
causes some hard-to-understand errors:
8: return R.pluck('id', items)
^^^^^^^^^^^^^^^^^^^^ call of method `pluck`. Function cannot be called on any member of intersection type
8: return R.pluck('id', items)
^^^^^^^ intersection
Member 1:
v
819: declare function pluck<
820: V,
821: K: string | number,
...:
826: ): Array<V>;
----------^ function type. See lib: flow-typed/npm/ramda_v0.x.x.js:819
Error:
8: return R.pluck('id', items)
^^^^^ array type. Has some incompatible type argument with
822: T: Array<Array<V> | { [key: string]: V }>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ array type. See lib: flow-typed/npm/ramda_v0.x.x.js:822
Type argument `T` is incompatible:
822: T: Array<Array<V> | { [key: string]: V }>
^^^^^^^^ array type. This type is incompatible with. See lib: flow-typed/npm/ramda_v0.x.x.js:822
7: function pluckIds<V, T: Array<{ [key: string]: V }>>(items: T) {
^^^^^^^^^^^^^^^^^^^^ object type
Isn't Array<{ [key: string]: V }> a narrower type of Array<Array<V> | { [key: string]: V }>? Why wouldn't it pass type checking?
Oops, seems to be related to covariance / contravariance.
@iwinux How you solve this problem? Have similar
Most helpful comment
@iwinux How you solve this problem? Have similar