【发布时间】:2022-12-16 02:37:40
【问题描述】:
标题很长,但本质上在 react-hook-form 中的 fieldArray 定义上有一个 Type 'string' is not assignable to type 'never'.ts(2322) fieldArray.d.ts(7, 5): The expected type comes from property 'name' which is declared here on type 'UseFieldArrayProps<FormValues, never, "id">' 错误,它有时会消失,但大多数时候都存在,我不知道为什么会存在,因为所有示例都这样显示它有时没有任何变化就消失了。有谁知道问题出在哪里?为什么打字稿抱怨?
我试过更改版本,重新排序控件和名称值(它删除了一次错误,当我再次交换它们时它又回来了,无论我再次交换它们多少次它都留在那里)。
这是其中一个错误,我一点也不知道它是从哪里来的。
Codesandbox 链接在这里:https://codesandbox.io/s/react-hook-form-list-of-numbers-s6zg2p?file=%2Fsrc%2FApp.tsx
编辑:错误特别出现在第 35 行。
【问题讨论】:
标签: reactjs typescript react-hook-form