Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…74179) In #73059 we added build-time checks for the forbidden usage of `this` and `arguments` in server functions. A nested function expression is however allowed to use these expressions. fixes #74181 To add a bit more context: `this` is forbidden in server actions because the Next.js compiler hoists inline server actions out of their original location into the module scope, so that they can be imported and invoked by the action handler. Due to this hoisting, the `this` context gets lost and is not available to the server action. To prevent surprising runtime errors for such cases, we emit a build error to provide feedback to developers as early as possible. However, nested function declarations or function expressions create a new `this` context, and in those it's allowed to access `this` and `arguments`. For consistency, and to prevent surprises when refactoring server actions, we apply the same rules for module-level server actions.
- Loading branch information