Closed valentinludu closed 1 month ago
Cannot reproduce the issue:
My guess is you just need to uninstall zod and @typeschema/zod, maybe delete node_modules and lockfile as well, then reinstall dependencies and reload the editor. TypeSchema works with dynamic imports and TypeScript magic, so it causes errors sometimes. If the issue persists I'll need a reproduction link to investigate this.
I tested it inside a CodeSandbox and the errors are not present. So it must be something on my end. I don't have "zod" and "@typeschema/zod" installed so I will try to delete node_modules, lock file and see if I get it to work.
Thank you for the quick response. I will try it out and come back if I have any issues.
Any updates on this issue?
After deleting package-lock and node_modules, now useAction types are working.
On the other hand defineMetadataSchema is still throwing that type error.
I just added @ts-ignore
for now so I can continue my work.
Kinda weird, have you tried reloading the editor?
Yes. Still there.
Most certainly it's because I am in a monorepo. Unfortunately I can't pin where the actual problem is.
Does v7.2.0 solve this issue? next-safe-action now ships with built-in support for multiple validation libraries. You can find more information about that in this discussion and on this page of the website.
After I updated the lib to the latest version 7.4.1, all the TypeScript errors are gone. I tested with TypeScript 5.4 and 5.5 because I had an issue with v5.5. as well and that is fixed too.
Thanks a million. Issue can be closed!
That's great, thanks for the feedback!
Are you using the latest version of this library?
Is there an existing issue for this?
Describe the bug
I tryied a zod schema and works fine.
But with a yup schema:
Reproduction steps
Using "typescript": "^5.4.2", "@typeschema/yup": "^0.13.3", "next": "14.1.1", "react": "^18.2.0", "next-safe-action": "^7.1.0"
My client:
defineMetadataSchema throws:
Using useAction in the FE throws a TypeError:
const { execute, executeAsync, result, status, reset, isIdle, isExecuting, hasSucceeded, hasErrored } = useAction(actionOnboarding);
useAction expects Zod:
Expected behavior
useAction should expect the yup schema and not the zod one. defineMetadataSchema should accept yup.
Minimal reproduction example
https://github.com
Operating System
macOS
Library version
7.1.0
Next.js version
14.1.1
Additional context
No response