使用flow更好地为函数props添加注释

时间:2017-09-01 15:44:14

标签: reactjs redux flowtype

我对组件有以下类型定义:

type Props = {
  address: {
    addressIndex: number,
    entryState: string
  },
  changeEntryState: Function,
  change: Function,
  untouch: Function,
  clearApplicantFields: Function
};

功能非常通用,我可以做些什么来使这个更具体?

它们都是redux操作,changeuntouch来自redux-form

1 个答案:

答案 0 :(得分:1)

例如

changeEntryState: (val: string) => number

changeEntryState: (str: string, bool?: boolean, ...nums: Array<number>) => void