I get the following error when I try to build my react app using react-hook-form in TS:
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>}`;
And here's my build command:
yarn tsc --emitDeclarationOnly && tsc-alias -p tsconfig.json
Here's my 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__/**/*"
]
}
I'm using react-hook-form version 7.6.6. Any suggestion on how to fix this would be much appreciated!
According to this discussion, react-hook-form
v7 needs TS 4.1 above
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With