Skip to content
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

[NEXT-1137] "use server" throws error for destructuring assignment export #49378

Closed
1 task done
JoseVSeb opened this issue May 6, 2023 · 3 comments · Fixed by #49600
Closed
1 task done

[NEXT-1137] "use server" throws error for destructuring assignment export #49378

JoseVSeb opened this issue May 6, 2023 · 3 comments · Fixed by #49600
Assignees
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.

Comments

@JoseVSeb
Copy link

JoseVSeb commented May 6, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Home Single Language
    Binaries:
      Node: 18.14.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.4.1
      eslint-config-next: 13.4.1
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/musing-shockley-gevrg3?file=%2FREADME.md

To Reproduce

"use server";
// ...
export const { sampleFunction } = someObject; // sampleFunction is async function.

Describe the Bug

Only async functions are allowed to be exported in a "use server" file is thrown at compilation.

Expected Behavior

No error should be thrown as only async functions are exported even if through destructuring.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1137

@JoseVSeb JoseVSeb added the bug Issue was opened via the bug report template. label May 6, 2023
@JoseVSeb
Copy link
Author

JoseVSeb commented May 6, 2023

FYI, there's a simple workaround but it's an unnecessary repetition, and it's still a bug.

"use server"
// ...
const { sampleFunction } = someObject;
export { sampleFunction };

@JoseVSeb
Copy link
Author

JoseVSeb commented May 7, 2023

this doesn't work either:

"use server";

export { sampleFunction } from "./someModule";

@shuding shuding added the linear: next Confirmed issue that is tracked by the Next.js team. label May 10, 2023
@shuding shuding changed the title "use server" throws error for destructuring assignment export [NEXT-1137] "use server" throws error for destructuring assignment export May 10, 2023
@shuding shuding self-assigned this May 10, 2023
shuding added a commit that referenced this issue May 10, 2023
Because of the flexibility of export declarations, we can't know the
exact export type of exported values so we should allow all of them.
Especially when we already have runtime checks.
fix #49378
fix NEXT-1137
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants