gpt4 book ai didi

reactjs - 使用 TS 使用 react-hook-form 构建应用程序时出错

转载 作者:行者123 更新时间:2023-12-04 15:57:16 26 4
gpt4 key购买 nike

当我尝试在 TS 中使用 react-hook-form 构建我的 React 应用程序时出现以下错误:

node_modules/react-hook-form/dist/types/utils.d.ts:24:77 - error TS1005: '?' expected.

24 declare type PathImpl<K extends string | number, V> = V extends Primitive ? `${K}` : `${K}` | `${K}.${Path<V>}`;
~~~

node_modules/react-hook-form/dist/types/utils.d.ts:24:84 - error TS1005: ';' expected.

24 declare type PathImpl<K extends string | number, V> = V extends Primitive ? `${K}` : `${K}` | `${K}.${Path<V>}`;
~

node_modules/react-hook-form/dist/types/utils.d.ts:24:110 - error TS1005: '(' expected.

24 declare type PathImpl<K extends string | number, V> = V extends Primitive ? `${K}` : `${K}` | `${K}.${Path<V>}`;
这是我的构建命令:
yarn tsc --emitDeclarationOnly && tsc-alias -p tsconfig.json
这是我的 tsconfig.json:
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": false,
"jsx": "react",
"declaration": true,
"outDir": "dist",
"rootDir": "src",
"downlevelIteration": true,
"noImplicitAny": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"noEmit": false,
"baseUrl": "./src",
"paths": {
"@context/*": [
"context/*"
],
"@types": [
"types/index.ts"
]
}
},
"include": [
"src/**/*",
],
"exclude": [
"node_modules/",
"./src/**/*.stories.tsx",
"./src/**/*.test.tsx",
"./src/**/__mocks__/**/*"
]
}
我正在使用 react-hook-form 版本 7.6.6。任何有关如何解决此问题的建议将不胜感激!

最佳答案

根据这个discussion , react-hook-form v7 需要 TS 4.1 以上

关于reactjs - 使用 TS 使用 react-hook-form 构建应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68006172/

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