vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.94k stars 26.97k forks source link

Server Actions that are hybrid types are compiled to `{}` causing `TypeError` #67051

Open purfectliterature opened 4 months ago

purfectliterature commented 4 months ago

Link to the code that reproduces this issue

To Reproduce

  1. Start the application with npm run dev.
  2. Click on "Create user".
  3. Witness the Error: operation(...) is not a function when clearly it should have been an async function.

[!NOTE] Please refer to README.md for more information about this error.

Current vs. Expected behavior

Expected behaviour is for createUser to actually be compiled as an async function with a hybrid type. Not an empty object {}.

This wasn't the case and everything was fine up till next@14.1.0. Since next@14.1.1, I get this error. In the reproduction CodeSandbox, try running npm i next@14.1.0; npm run dev to see the app working fine.

If you prefer to run it locally, you can clone the repository here: https://github.com/purfectliterature/typeerror-starter.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Thu May 30 21:30:12 PDT 2024; root:xnu-11215.0.31.511.2~1/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10
Binaries:
  Node: 20.14.0
  npm: 10.7.0
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 14.2.4 // Latest available version is detected (14.2.4).
  eslint-config-next: 14.2.4
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Output (export/standalone), Runtime, SWC, Webpack

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

It was fine up till next@14.1.0 and it breaks in next@14.1.1.

Potentially related to https://github.com/vercel/next.js/issues/62953 (?) [I posted there!] but that was closed and my use case is still erroring even in the latest release of Next.js at next@14.2.4.

Please refer to my README.md for more information about the error, how to reproduce, and some more context about my use case. It's not that long and very concise!

purfectliterature commented 1 month ago

Any updates on this?

Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!