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

Regression: Typescript error with "to.be.a" #707

Closed
xsrvmy opened this issue Feb 8, 2022 · 3 comments · Fixed by #709
Closed

Regression: Typescript error with "to.be.a" #707

xsrvmy opened this issue Feb 8, 2022 · 3 comments · Fixed by #709

Comments

@xsrvmy
Copy link

xsrvmy commented Feb 8, 2022

Describe the bug

A typescript error occurs when using expect(...).to.be.a(...).

This seems to be a regression: there is no typescript error on the version used by the demo stackblitz (0.0.136).

Reproduction

https://stackblitz.com/edit/node-spzkwl?file=test%2Fbasic.test.ts&view=editor

Note the typescript error on line 20.

System Info

System:
    OS: Linux 5.16 Arch Linux
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11900H @ 2.50GHz
    Memory: 18.32 GB / 31.08 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 16.13.2 - ~/.volta/tools/image/node/16.13.2/bin/node
    Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
    npm: 8.4.1 - ~/.volta/tools/image/npm/8.4.1/bin/npm
  Browsers:
    Firefox: 96.0.3
  npmPackages:
    @vitejs/plugin-react: ^1.0.7 => 1.1.4 
    vite: ^2.7.2 => 2.7.13 
    vitest: ^0.2.8 => 0.2.8 


### Used Package Manager

npm

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitest-dev/vitest/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitest-dev/vitest/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitest.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitest-dev/vitest/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions) or join our [Discord Chat Server](https://chat.vitest.dev).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
@stygian-desolator
Copy link
Contributor

It looks like a problem with @types/chai, the type of a is not correct.

@sheremet-va
Copy link
Member

sheremet-va commented Feb 9, 2022

It looks like a problem with @types/chai, the type of a is not correct.

This is interesting. Typeof a is callable, but most of the other chainables are not, which begs the questing of how do we support it? Right now I just replicated the Chai.Assertion type with this bug.

@xsrvmy
Copy link
Author

xsrvmy commented Feb 9, 2022

Interestingly if I import expect from chai then there isn't a problem.
I just used ts-ignore for now.

@antfu antfu closed this as completed in #709 Feb 9, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants