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

Cypress adds should to every object? #16548

Closed
juanmendes opened this issue May 17, 2021 · 4 comments · Fixed by #16744
Closed

Cypress adds should to every object? #16548

juanmendes opened this issue May 17, 2021 · 4 comments · Fixed by #16744
Assignees
Labels
type: typings Issue related to Cypress types (for TypeScript)

Comments

@juanmendes
Copy link

I use cypress with the cucumber plugin and noticed that the following TypeScript code which compiles without a problem but crashes at runtime.

const a = 1;
a.should("be.visible");

This is because the following which is downloaded when I npm i cypress: node_modules/cypress/types/chai/index.d.ts:1943

interface Object {
    should: Chai.Assertion;
}

This is causing TypeScript to give me false positives everywhere because I called should() on something that is not a Cypress Chainable but I don't find out about it until runtime.

Augmenting Object's TypeScript definition with an extra method seems like something we did away with since prototype JS taught us how bad it was. Why is it being done? Should I file a bug? It really stinks to have to run a file to be told I have what should be compilation errors.

Originally posted by @juanmendes in #16526

@jennifer-shehane
Copy link
Member

@juanmendes We'll review a PR to fix any type bugs if you'd like to submit one.

@jennifer-shehane jennifer-shehane added type: typings Issue related to Cypress types (for TypeScript) stage: ready for work The issue is reproducible and in scope labels May 17, 2021
@juanmendes
Copy link
Author

@juanmendes We'll review a PR to fix any type bugs if you'd like to submit one.

I can work on this if there's some direction on what to do, so I can avoid working down a rabbit hole

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels May 31, 2021
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Jun 2, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 2, 2021

The code for this is done in cypress-io/cypress#16744, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 7, 2021

Released in 7.5.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.5.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: typings Issue related to Cypress types (for TypeScript)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants