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 errors on optional disposer returns #3023

Closed
1 task done
cpakken opened this issue May 29, 2024 · 2 comments
Closed
1 task done

noConfusingVoidType errors on optional disposer returns #3023

cpakken opened this issue May 29, 2024 · 2 comments
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Comments

@cpakken
Copy link

cpakken commented May 29, 2024

Environment information

CLI:
  Version:                      1.7.3    
  Color support:                true     

Platform:
  CPU Architecture:             x86_64   
  OS:                           windows  

Environment:
  BIOME_LOG_DIR:                unset    
  NO_COLOR:                     unset    
  TERM:                         unset    
  JS_RUNTIME_VERSION:           "v22.0.0"
  JS_RUNTIME_NAME:              "node"   
  NODE_PACKAGE_MANAGER:         unset    

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

Linter:
  Recommended:                  true
  All:                          false
  Rules:                        suspicious/noConfusingVoidType = "off"
                                suspicious/noExplicitAny = "off"

Workspace:
  Open Documents:               0

Rule name

noConfusingVoidType

Playground link

https://biomejs.dev/playground/?code=ZgB1AG4AYwB0AGkAbwBuACAAYwByAGUAYQB0AGUATABpAHMAdABlAG4AZQByACgAYwBhAGwAbABiAGEAYwBrADoAIAAoACkAIAA9AD4AIAAoACgAKQAgAD0APgAgAHYAbwBpAGQAKQAgAHwAIAB2AG8AaQBkACkAewAKACAAIAByAGUAdAB1AHIAbgAgAG4AdQBsAGwACgB9AA%3D%3D

Expected result

Sometimes I have a callback that can optionally return a disposer

function createListener(callback: (e) => (() => void) | void))

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Sec-ant Sec-ant added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels Jun 15, 2024
@Conaclos
Copy link
Member

I think that the function could better be typed with undefined because you are likely to check if the result is not undefined.

function createListener(callback: (e) => (() => void) | undefined)) {}

@Conaclos
Copy link
Member

I think we should not address this, because the function returns something. undefined should be used instead of void here.

@Conaclos Conaclos closed this as not planned Won't fix, can't repro, duplicate, stale Jul 16, 2024
@Conaclos Conaclos removed the S-Bug-confirmed Status: report has been confirmed as a valid bug label Jul 16, 2024
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
Projects
None yet
Development

No branches or pull requests

3 participants