You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Download deps and build project (pnpm i && pnpm build).
During build you should recieve folowing type error:
./app/page.tsx:17:16
Type error: Type '(formData: FormData) => Promise<{ data: string; }>' is not assignable to type 'string | ((formData: FormData) => void | Promise<void>)'.
Type '(formData: FormData) => Promise<{ data: string; }>' is not assignable to type '(formData: FormData) => void | Promise<void>'.
Type 'Promise<{ data: string; }>' is not assignable to type 'void | Promise<void>'.
Type 'Promise<{ data: string; }>' is not assignable to type 'Promise<void>'.
Type '{ data: string; }' is not assignable to type 'void'.
15 | }
16 |
> 17 | return <form action={createInvoice}>...</form>
| ^
18 | }
Linting and checking validity of types ... ELIFECYCLE Command failed with exit code 1.
Current vs. Expected behavior
Allow data to be returned from server action.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
Available memory (MB): 7843
Available CPU cores: 8
Binaries:
Node: 20.16.0
npm: 10.8.1
Yarn: 1.22.22
pnpm: 9.11.0
Relevant Packages:
next: 15.0.0-canary.173 // Latest available version is detected (15.0.0-canary.173).
eslint-config-next: N/A
react: 19.0.0-rc-3edc000d-20240926
react-dom: 19.0.0-rc-3edc000d-20240926
typescript: 5.3.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
TypeScript
Which stage(s) are affected? (Select all that apply)
Link to the code that reproduces this issue
https://github.com/grzegorzpokorski/next-server-action-return-type
To Reproduce
pnpm i && pnpm build
).Current vs. Expected behavior
Allow data to be returned from server action.
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024 Available memory (MB): 7843 Available CPU cores: 8 Binaries: Node: 20.16.0 npm: 10.8.1 Yarn: 1.22.22 pnpm: 9.11.0 Relevant Packages: next: 15.0.0-canary.173 // Latest available version is detected (15.0.0-canary.173). eslint-config-next: N/A react: 19.0.0-rc-3edc000d-20240926 react-dom: 19.0.0-rc-3edc000d-20240926 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
TypeScript
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
The mentioned type error occurs after upgrading
@types/react
to version 18.3.9 and later.Example server action comes from documentation: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#forms
The text was updated successfully, but these errors were encountered: