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

Wrong TypeScript typing for toBeDateString (and possibly toBeHexadecimal) #381

Closed
AudunWA opened this issue Nov 10, 2021 · 2 comments · Fixed by #384
Closed

Wrong TypeScript typing for toBeDateString (and possibly toBeHexadecimal) #381

AudunWA opened this issue Nov 10, 2021 · 2 comments · Fixed by #384

Comments

@AudunWA
Copy link

AudunWA commented Nov 10, 2021

Bug

  • package version: 1.1.0
  • node version: v14.17.0
  • npm (or yarn) version: npm 7.24.1

The type for toBeDateString expects a string argument; see the example below:

it("Demonstrates the wrong typing", () => {
    const validDateString = new Date().toISOString();

    // TS2554: Expected 1 arguments, but got 0.
    expect(validDateString).toBeDateString();

    // Works
    (expect(validDateString).toBeDateString as any)();

    const validDateStringInObject = { validDateString };

    // The .not prefix does not work in cases like this
    expect(validDateStringInObject).toEqual({
        // TS2339: Property 'toBeDateString' does not exist on type 'InverseAsymmetricMatchers'.
        validDateString: expect.not.toBeDateString(),
    });
});

I suspect this issue might affect toBeHexadecimal as well.

@SimenB
Copy link
Member

SimenB commented Nov 10, 2021

PR welcome 🙂

dharkness pushed a commit to dharkness/jest-extended that referenced this issue Nov 13, 2021
dharkness pushed a commit to dharkness/jest-extended that referenced this issue Nov 13, 2021
dharkness pushed a commit to dharkness/jest-extended that referenced this issue Nov 13, 2021
@dharkness
Copy link
Contributor

Sorry for the churn. I accidentally pushed changes for a new PR to the branch. I deleted the PR and branch and started over.

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 a pull request may close this issue.

3 participants