TheEdoRan / next-safe-action

Type safe and validated Server Actions in your Next.js project.
https://next-safe-action.dev
MIT License
2.29k stars 35 forks source link

[BUG] build command is throwing an error #195

Closed muezz closed 4 months ago

muezz commented 4 months ago

Are you using the latest version of this library?

Is there an existing issue for this?

Describe the bug

When I try to run pnpm run build I get the following error:

> nsf-bug-report@0.1.0 build /Users/abdulmuezzejaz/Documents/Projects/test_apps/nsf-bug-report
> next build

  ▲ Next.js 14.2.4

   Creating an optimized production build ...
 ✓ Compiled successfully
   Linting and checking validity of types  ..Failed to compile.

./app/signin-dialog.tsx:41:30
Type error: Expected 1 arguments, but got 0.

  39 |               className=" flex justify-center w-[90%] gap-2 rounded-full p-8"
  40 |               variant="default"
> 41 |               onClick={() => execute()}
     |                              ^
  42 |               disabled={isExecuting}
  43 |             >
  44 |               Sign In with Google
 ELIFECYCLE  Command failed with exit code 1.

Reproduction steps

  1. Clone the provided repo,
  2. Run pnpm run build

Expected behavior

The provided repo has a sign-in dialog component. These is no error in the file but this linting error only appears on build.

Minimal reproduction example

https://github.com/muezz/nsf-bug-report.git

Operating System

macOS Sonoma

Library version

7.1.3

Next.js version

14.2.4

Additional context

No response

TheEdoRan commented 4 months ago

This is due to the TypeSchema library incompatibility with TypeScript >= 5.5. Installing the experimental version of next-safe-action should solve your issue, as explained here:

Additionally, even if you're not required to do this, if you're using VS Code, I also suggest to add this configuration in .vscode/settings.json, to tell the editor that you want to use the actual project TS version, instead of the default one that comes with it:

{
  "typescript.tsdk": "node_modules/typescript/lib"
}

Let me know if this fixes your issue, thanks.

muezz commented 4 months ago

@TheEdoRan I have added this in my settings file and I am still seeing this same issue when I try to build.

muezz commented 4 months ago

@TheEdoRan I have also tried the build command after installing the experimental version and I still have this issue.

TheEdoRan commented 4 months ago

Before writing my comment I did those steps and actually solve the build issue with your reproduction repo, so this is very weird. Can you please push the changes you've made to GitHub so I can take a look to the updated code? Thanks.

muezz commented 4 months ago

@TheEdoRan I tried a few things and after deleting .next, node_modules and pnpm-lock.yaml and running pnpm i, the project built fine.

So I think your solution was correct although I hope I will be able to move back to the stable version soon.

TheEdoRan commented 4 months ago

Great! By the way, experimental shares the same code as the stable version, the only difference is that it supports just Zod. Unfortunately TypeSchema is still incompatible with TS 5.5, I hope this will be solved soon too, but I'll merge any changes to main in the experimental branch in the meantime.