【发布时间】:2018-05-24 17:10:50
【问题描述】:
仍然很难在我的 react/redux 应用程序中使用 Flow 来检查所有内容。
输入我的操作时,我得到:
type MessageSentAction = { type: 'MSG_SENT',
message: string,
}
type Action = MessageSentAction | AnotherAction;
对此没有任何问题,但我想将类型 MSG_SENT 替换为常量。
const actionTypes = { MESSAGE_SENT = 'MSG_SENT'}
...
type MessageSentAction = { type: ActionTypes.MESSAGE_SENT,
message: string,
}
我怎样才能让它工作?我不希望动作字符串在动作、reducer 和类型中重复...... 上面的示例给出了一个错误:“Ineligible value used in/as flow type annotation.”
【问题讨论】: