[英]Flow type Generic types
I am trying to make a configurable type as follows: 我正在尝试使可配置类型如下:
import * as React from 'react';
type Identity<T: {}> = {
data: {
refetch: void => void,
T: {}
}
};
({ data }: Identity<{foo: string }>) => <div>{data.foo}</div>;
But I am getting: 但我得到:
Cannot get data.foo because property foo is missing in object type [1].
Am I missing something obvious? 我是否缺少明显的东西? This is the shape of graphql hoc return data.
这是graphql hoc返回数据的形状。
Thank you 谢谢
Did you mean: 你的意思是:
type RefetchObj = {
refetch: void => void,
}
type Identity<T: {}> = {
data: T & RefetchObj
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.