Skip to content

fix(vitest): loosen onConsoleLog return type - #5337

Merged
sheremet-va merged 2 commits into
vitest-dev:mainfrom
hi-ogawa:fix-loosen-onConsoleLog-type
Mar 5, 2024
Merged

fix(vitest): loosen onConsoleLog return type#5337
sheremet-va merged 2 commits into
vitest-dev:mainfrom
hi-ogawa:fix-loosen-onConsoleLog-type

Conversation

@hi-ogawa

@hi-ogawa hi-ogawa commented Mar 5, 2024

Copy link
Copy Markdown
Collaborator

Description

I think this is a minor paper cut and loosening it makes sense to allow something like:

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

Currently users need to rewrite it into a following, which seems unnecessary restriction. Also it seems some eslint rule doesn't like this form.

onConsoleLog(type) {
  if (type === 'stderr') {
    return false;
  }
}

I don't know about void vs undefined, so I kept void here.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify

netlify Bot commented Mar 5, 2024

Copy link
Copy Markdown

Deploy Preview for fastidious-cascaron-4ded94 canceled.

Name Link
🔨 Latest commit 95674ac
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65e66d5229f8d40008227632

@hi-ogawa
hi-ogawa marked this pull request as ready for review March 5, 2024 00:55

@AriPerkkio AriPerkkio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also ran into this annoying type issue. Glad to see this fixed!

@sheremet-va
sheremet-va merged commit 6d1b145 into vitest-dev:main Mar 5, 2024
@hi-ogawa
hi-ogawa deleted the fix-loosen-onConsoleLog-type branch March 5, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

onConsoleLog should be typed false | undefined or boolean | undefined

3 participants