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

typescript plugin regarding async actions not accurate #63743

Closed
juliusmarminge opened this issue Mar 26, 2024 · 1 comment · Fixed by #63748
Closed

typescript plugin regarding async actions not accurate #63743

juliusmarminge opened this issue Mar 26, 2024 · 1 comment · Fixed by #63748
Labels
bug Issue was opened via the bug report template. locked TypeScript Related to types with Next.js.

Comments

@juliusmarminge
Copy link
Contributor

juliusmarminge commented Mar 26, 2024

Link to the code that reproduces this issue

https://github.com/juliusmarminge/next-ts-plugin-async-serveraction

To Reproduce

Run npm i, then open app/_action.ts. See error:
CleanShot 2024-03-27 at 00 42 11@2x

Current vs. Expected behavior

The introduction of checking that actions are async functions seems to be quite inaccurate. As seen in the example above, both the exports are async functions, yet the TS plugin complains.

I'd expect both these exports to be valid. Afterall, they both do work runtime:

CleanShot 2024-03-27 at 00 41 45@2x

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: 1.22.19
  pnpm: 8.13.1
Relevant Packages:
  next: 14.2.0-canary.44 // Latest available version is detected (14.2.0-canary.44).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.3
Next.js Config:
  output: N/A

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

TypeScript (plugin, built-in types)

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

next dev (local)

Additional context

The rule testing for this was introduced in 14.2.0-canary.43 by this PR #63667

@juliusmarminge juliusmarminge added the bug Issue was opened via the bug report template. label Mar 26, 2024
@github-actions github-actions bot added the TypeScript Related to types with Next.js. label Mar 26, 2024
shuding pushed a commit that referenced this issue Mar 28, 2024
…#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
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. 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 Apr 12, 2024
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. locked TypeScript Related to types with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@juliusmarminge and others