我正在编写一个小型React Native应用程序,并且尝试使用Flow,但是我在任何地方都无法真正获得有关它的适当教程。
我不断收到错误:destructuring (Missing annotation)关于({ station })此代码第一行的内容:
destructuring (Missing annotation)
({ station })
const StationDetail = ({ station }) => { const { code, label, } = station;
station是一个 JSON响应 和code和label是strings其内部 JSON 。
station
code
label
strings
如何解决错误/警告?
我会这样写
type StationType = { code: String, label: String, } function StationDetail({ station } : {station : StationType}) => { const { code, label, } = station;
必须声明函数接受的对象参数的类型。