gpt4 book ai didi

javascript - 如何纠正流量警告: destructuring (Missing annotation)

转载 作者:行者123 更新时间:2023-12-03 13:00:51 27 4
gpt4 key购买 nike

我正在编写一个小型 React Native 应用程序,并且正在尝试使用 Flow,但我无法在任何地方真正获得有关它的正确教程。

我不断收到错误:关于此代码第一行中的 ({ station })解构(缺少注释):

const StationDetail = ({ station }) => {
const {
code,
label,
} = station;

station 是一个 json 响应codelabel 是里面的 string那个json

如何修复错误/警告?

最佳答案

我会把它写成

type StationType = {
code: String,
label: String,
}

function StationDetail({ station } : {station : StationType}) => {
const {
code,
label,
} = station;

需要声明函数接受的对象参数的类型。

关于javascript - 如何纠正流量警告: destructuring (Missing annotation),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41443242/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com