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

onConsoleLog should be typed false | undefined or boolean | undefined #5317

Closed
4 tasks done
ST-DDT opened this issue Feb 29, 2024 · 1 comment · Fixed by #5337
Closed
4 tasks done

onConsoleLog should be typed false | undefined or boolean | undefined #5317

ST-DDT opened this issue Feb 29, 2024 · 1 comment · Fixed by #5337
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) types

Comments

@ST-DDT
Copy link
Contributor

ST-DDT commented Feb 29, 2024

Clear and concise description of the problem

According to @bradzacher in typescript-eslint/typescript-eslint#8576 (comment) the current typing of the method is flawed. As the current void part of the method would indicate that you shouldn't care about the result.

Suggested solution

Change the return signature of onConsoleLog to false | undefined or boolean | undefined.

The later variant especially would allow for ternaries or simple return expressions like:

onConsoleLog(type) {
  return type != 'stderr';
}

Alternative

No response

Additional context

https://vitest.dev/config/#onconsolelog

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Mar 1, 2024

Good point. I don't think restricting it to false makes much sense. Probably it was just a small oversight and the similar one just below already have boolean | void, so probably we can do the same for onConsoleLog.

onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void
/**
* Enable stack trace filtering. If absent, all stack trace frames
* will be shown.
*
* Return `false` to omit the frame.
*/
onStackTrace?: (error: Error, frame: ParsedStack) => boolean | void

@hi-ogawa hi-ogawa added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Mar 1, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants