-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Not compatible with Typescript >= 5.5.2 #180
Comments
Will look into it soon, thanks. |
I can confirm schema validations don't work with typescript 5.5.2, I get |
After some tests, I identified the problem in TypeSchema, which breaks with TypeScript 5.5. I've just opened an issue on the TypeSchema repo for this bug: |
Might be related to: |
I know this is a pretty new issue, but a quick easy workaround for me was to just downgrade typescript. I just locked at typescript 5.4.5 (I use the LSP that comes with Mason) for now, it seems to work perfectly. |
@RolandRFuchs92 yes, the workaround is to downgrade to TypeScript v5.4. The issue appears to be related to a compiler change in TS 5.5.2, which broke ts-patch and so TypeSchema as well. |
I've just released next-safe-action v7.1.4-experimental.1, that should work fine with TypeScript 5.5. Note that this version only works with Zod, it's essentially the same codebase without TypeSchema support, as it's currently preventing the ability to upgrade to TS 5.5. So, if you're using Zod and TS 5.5, you can install experimental next-safe-action with this command: npm i next-safe-action@experimental # or pnpm, yarn P.S.: Even though the tag is named "experimental", as explained above the codebase is essentially the same as the stable v7. It's named like that because I don't think this will be an actual library change, as it's nice to have multiple validation libraries support. However, it's also nice to use the latest TS version, so until TypeSchema is compatible with it, I think this is a good solution. |
Hey! Just to let you know is working for me using TS 5.5 and zod. Thanks for your amazing work! |
I'm trying the experimental version, but I can't destruct the response because is possibly undefined. |
I see. I was previously using a pre-release of v7 and it wasn't yet the case, so I thought it was an error. It didn't help the fact that in the docs that behavior is not shown. |
Fixed. It was left over from v6 docs. |
- fix issue Schema being typed as any. TheEdoRan/next-safe-action#180
This should probably be added to docs as well if not already there. |
@aniketbiprojit https://next-safe-action.dev/docs/troubleshooting#schema-and-parsedinput-are-typed-any-broken-types-and-build-issues But I'll add a note on the getting started page too, soon. Also, I'm thinking of implementing a built-in system to support a small number of validation libraries (zod, valibot, yup), instead of relying on a third party library. |
This issue should be solved in v7.2.0. next-safe-action now ships with a built-in system for supporting multiple validation libraries, at this time Zod (the default one), Valibot and Yup. You can now use them even with the Edge Runtime and obviously with TS >= 5.5. More information about that in this discussion and on this page of the website. Please let me know if you encounter any bugs when updating to v7.2.0, thanks! EDIT: Be sure to update to v7.2.1, which solves a build bug introduced in v7.2.0. |
Any chance getting this fixed in v6 too? |
Are you using the latest version of this library?
Is there an existing issue for this?
Describe the bug
parsedInput
returning any,schema
defined by ZodWill provide a minimal repo soon.
Reproduction steps
parsedInput
Expected behavior
parsedInput
should have the correct type informationMinimal reproduction example
Code Sandbox link
Operating System
MacOS 14
Library version
7.2.0
Next.js version
14.2.4
Additional context
No response
The text was updated successfully, but these errors were encountered: