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

fix: switch ExpectStatic any types to AsymmetricMatcher<unknown>, with DeeplyAllowMatchers<T> #7016

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JoshuaKGoldberg
Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg commented Dec 3, 2024

Description

Switches the two any types to unknown AsymmetricMatcher<unknown>, and updated APIs such as toEqual<T> to deeply allow those using a new DeeplyAllowMatchers<T>.

Sending as a draft for reference.

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.
    • I don't know how to best do this. Do you want a type test somewhere? I added a types.test.ts file but am 100% sure I missed a much better way to do that
  • 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:.

@JoshuaKGoldberg JoshuaKGoldberg changed the title fix: switch ExpectSTatic any types to unknown fix: switch ExpectStatic any types to unknown Dec 3, 2024
Copy link

netlify bot commented Dec 3, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 3ce8784
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/674f4d9078b4770008db36bb
😎 Deploy Preview https://deploy-preview-7016--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sheremet-va
Copy link
Member

sheremet-va commented Dec 4, 2024

How is this going to work?

expect(obj).toEqual<{
  id: string
  name: string
}>({
  id: expect.any(String),
  name: 'Amelia',
})

Error:

Type 'unknown' is not assignable to type 'string'.ts(2322)

@JoshuaKGoldberg
Copy link
Contributor Author

How is this going to work?

expect(obj).toEqual<{
  id: string
  name: string
}>({
  id: expect.any(String),
  name: 'Amelia',
})

Error:

Type 'unknown' is not assignable to type 'string'.ts(2322)

Aha! Updated to use a DeeplyAllowMatchers.

@JoshuaKGoldberg JoshuaKGoldberg changed the title fix: switch ExpectStatic any types to unknown fix: switch ExpectStatic any types to AsymmetricMatcher<unknown>, with DeeplyAllowMatchers<T> Dec 6, 2024
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This keeps getting updated and I don't know why. 🤷 I'll revert it if it's still here if & when the PR gets un-drafted.

@hi-ogawa hi-ogawa mentioned this pull request Dec 8, 2024
6 tasks
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.

2 participants