Skip to content

Commit

Permalink
fix(next-typescript-plugin): allow call expression for server actions (
Browse files Browse the repository at this point in the history
…#63748)

cc @shuding

### Why?

The typescript plugin in #63667 does not target the call expression or
assigned actions.

```ts
'use server'

function action() {
  return async function() {
    return 'foo'
  }
}

async function action2() {
  return 'foo'
}

export const callAction = action() // call expression
export const assignedAction = action2 // assigned
```

### Current

![Screenshot 2024-03-27 at 2 29
04 PM](https://github.com/vercel/next.js/assets/120007119/7b35edba-c423-402b-94e7-9725c4d3cccc)

### Fixed

![Screenshot 2024-03-27 at 2 29
41 PM](https://github.com/vercel/next.js/assets/120007119/e9b7c164-4053-4c56-a4fb-eb4722094355)

x-ref: #63667
Closes #63743
  • Loading branch information
devjiwonchoi authored Mar 28, 2024
1 parent 72ef9d9 commit 19c1916
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/next/src/server/typescript/rules/server-boundary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ const serverBoundary = {
initializer &&
(ts.isArrowFunction(initializer) ||
ts.isFunctionDeclaration(initializer) ||
ts.isFunctionExpression(initializer))
ts.isFunctionExpression(initializer) ||
ts.isCallExpression(initializer) ||
ts.isIdentifier(initializer))
) {
diagnostics.push(
...serverBoundary.getSemanticDiagnosticsForFunctionExport(
Expand Down Expand Up @@ -127,6 +129,8 @@ const serverBoundary = {
| tsModule.FunctionDeclaration
| tsModule.ArrowFunction
| tsModule.FunctionExpression
| tsModule.CallExpression
| tsModule.Identifier
) {
const ts = getTs()
const typeChecker = getTypeChecker()
Expand Down

0 comments on commit 19c1916

Please sign in to comment.