Skip to content

feat: Have Inverse exportable in types.ts #15704

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

Merged
merged 2 commits into from
Jun 27, 2025

Conversation

dprevost-LMI
Copy link
Contributor

@dprevost-LMI dprevost-LMI commented Jun 26, 2025

Summary

The expect-webdriverio is based on the expect library, and it would be helpful if the Inverse<Matchers> could be exportable here

When implementing our Expect interface, we have a new method like soft where we want to reuse Inverse as shown below:

// Copied while we would like to export it!
type Inverse<M> = {
    /**
     * Inverse next matcher. If you know how to test something, `.not` lets you test its opposite.
     */
    not: M;
}

declare namespace ExpectWebdriverIO {
    Inverse<R, T> = ExpectWebdriverIO.Matchers<R, T> & Inverse<ExpectWebdriverIO.Matchers<R, T>>

    interface Expect extends ExpectLibExpect {

        <T = unknown>(actual: T): MatchersAndInverse<void, T>;
        soft<T = unknown>(actual: T): T extends PromiseLikeType ? MatchersAndInverse<Promise<void>, T> : MatchersAndInverse<void, T>
    }

Test plan

Used in jest-expect and yarn build passed!

Have this one exportable to reuse instead of copying it
Copy link

netlify bot commented Jun 26, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1148076
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/685d3d003a55da000839f1d6
😎 Deploy Preview https://deploy-preview-15704--jestjs.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 project configuration.

Copy link

pkg-pr-new bot commented Jun 26, 2025

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15704

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15704

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15704

create-jest

npm i https://pkg.pr.new/create-jest@15704

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15704

expect

npm i https://pkg.pr.new/expect@15704

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15704

jest

npm i https://pkg.pr.new/jest@15704

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15704

jest-circus

npm i https://pkg.pr.new/jest-circus@15704

jest-cli

npm i https://pkg.pr.new/jest-cli@15704

jest-config

npm i https://pkg.pr.new/jest-config@15704

@jest/console

npm i https://pkg.pr.new/@jest/console@15704

@jest/core

npm i https://pkg.pr.new/@jest/core@15704

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15704

jest-diff

npm i https://pkg.pr.new/jest-diff@15704

jest-docblock

npm i https://pkg.pr.new/jest-docblock@15704

jest-each

npm i https://pkg.pr.new/jest-each@15704

@jest/environment

npm i https://pkg.pr.new/@jest/environment@15704

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15704

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15704

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15704

@jest/expect

npm i https://pkg.pr.new/@jest/expect@15704

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15704

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15704

@jest/globals

npm i https://pkg.pr.new/@jest/globals@15704

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15704

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15704

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15704

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15704

jest-message-util

npm i https://pkg.pr.new/jest-message-util@15704

jest-mock

npm i https://pkg.pr.new/jest-mock@15704

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15704

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15704

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15704

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15704

jest-resolve

npm i https://pkg.pr.new/jest-resolve@15704

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15704

jest-runner

npm i https://pkg.pr.new/jest-runner@15704

jest-runtime

npm i https://pkg.pr.new/jest-runtime@15704

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15704

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15704

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15704

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15704

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15704

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15704

@jest/transform

npm i https://pkg.pr.new/@jest/transform@15704

@jest/types

npm i https://pkg.pr.new/@jest/types@15704

jest-util

npm i https://pkg.pr.new/jest-util@15704

jest-validate

npm i https://pkg.pr.new/jest-validate@15704

jest-watcher

npm i https://pkg.pr.new/jest-watcher@15704

jest-worker

npm i https://pkg.pr.new/jest-worker@15704

pretty-format

npm i https://pkg.pr.new/pretty-format@15704

commit: 1148076

@mrazauskas
Copy link
Contributor

You should also export it from the index.ts file.

@mrazauskas
Copy link
Contributor

And perhaps you could import and reuse the same Inverse here:

type Inverse<Matchers> = {
/**
* Inverse next matcher. If you know how to test something, `.not` lets you test its opposite.
*/
not: Matchers;
};

@mrazauskas
Copy link
Contributor

Looks good to me. You should turn off the draft mode, so that the maintainers could take a look and merge.

@dprevost-LMI
Copy link
Contributor Author

Looks good to me. You should turn off the draft mode, so that the maintainers could take a look and merge.

Will do, wanted to double-check pipeline failure before in case I blew something, but sounds related to something else!

@dprevost-LMI dprevost-LMI marked this pull request as ready for review June 26, 2025 14:35
@mrazauskas
Copy link
Contributor

related to something else

Indeed, the errors in CI should be fixed by #15701.

Copy link
Member

@cpojer cpojer left a comment

Choose a reason for hiding this comment

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

Cool! Thanks.

@cpojer cpojer merged commit c88d1f1 into jestjs:main Jun 27, 2025
58 of 76 checks passed
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.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy