4

Im trying to use zod with react-hook-form but the import hook form resolver gives the error below

Could not find a declaration file for module '@hookform/resolvers/zod'. '/pradeep/projects/react/safe-zone/node_modules/@hookform/resolvers/zod/dist/zod.mjs' implicitly has an 'any' type.

enter image description here

4
  • arunmichaeldsouza.com/blog/aliasing-module-paths-in-node-js Commented Jun 4, 2023 at 9:44
  • you can try adding a paths configuration in your package.json file to create an alias for the module import. Commented Jun 4, 2023 at 9:45
  • 1
    "compilerOptions": { "baseUrl": ".", "paths": { "@hookform/resolvers/zod": ["./node_modules/@hookform/resolvers/zod/dist/zod.mjs"] } } Commented Jun 4, 2023 at 9:45
  • I tried this but no luck. Commented Jun 5, 2023 at 2:37

2 Answers 2

7

I got this resolved by running the below cmd

npm i -save-dev @hookform/resolvers
Sign up to request clarification or add additional context in comments.

1 Comment

now will the build will be created? as we have installed it in dev dependency? issues in production?
0

Check the version of @hookform/resolvers being installed. for me it was installing version 2.*.* instead of the latest version ^3.9.0.

I updated the @hookform/resolvers version manually in the package.json. Then run yarn install.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.