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

🐛 noConfusingVoidType: allow Promise<void> | void #604

Closed
1 task done
nstepien opened this issue Oct 26, 2023 · 0 comments · Fixed by #611
Closed
1 task done

🐛 noConfusingVoidType: allow Promise<void> | void #604

nstepien opened this issue Oct 26, 2023 · 0 comments · Fixed by #611
Assignees
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Enhancement Status: Improve an existing feature

Comments

@nstepien
Copy link
Contributor

Environment information

CLI:
  Version:                      1.3.1
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           "v21.1.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.2.1"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    true
  VCS disabled:                 true

Workspace:
  Open Documents:               0

What happened?

export async function test(fn: () => Promise<void> | void) {
  await fn();
  return 'ok';
}

We use this pattern in our codebase, we pass functions that may or may not be async, so

  • we have the Promise<void> return type for async functions, combined with the no-floating-promises allows us to ensure we don't forget to await it
  • we have the void return type for sync functions, otherwise TS would complain

Expected result

no-invalid-void-type considers this union to be valid, but Biome doesn't. I'd expect parity.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Conaclos Conaclos added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Enhancement Status: Improve an existing feature labels Oct 26, 2023
@unvalley unvalley self-assigned this Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Enhancement Status: Improve an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants