实用功能将所有内容转换为可选

时间:2017-08-29 04:28:36

标签: flowtype

我很多时候发现自己作为某个select max(superstar) (SELECT superstars.name,COUNT(superstar01) as superstar FROM smackdown_teams JOIN superstars on smackdown_teams.superstar01 = superstars.id GROUP by superstar01 Order by COUNT(superstar01) desc UNION SELECT superstars.name,COUNT(superstar02) as superstar FROM smackdown_teams JOIN superstars on smackdown_teams.superstar02 = superstars.id GROUP by superstar02 Order by COUNT(superstar02) desc) 类型的arg传入但是每个键都是可选的,只需要至少一个。

例如:

Shape

是否有实用程序功能可以从type Shape = { +isFetching: boolean, +errorFetching: null | string } type ShapeOpt = { isFetching?: boolean, errorFetching?: boolean } function set(data: ShapeOpt) { for (const key in data) { global[key] = data[key]; } } 转换为Shape

1 个答案:

答案 0 :(得分:1)

有一个$Shape<Type>助手用于生成对象类型,其中每个键都是可选的。但是我不知道如何说自动需要至少一个项目。