Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Types erroneously doesn't take into account JQuery-wrapping #8440

Closed
badeball opened this issue Aug 28, 2020 · 2 comments
Closed

Types erroneously doesn't take into account JQuery-wrapping #8440

badeball opened this issue Aug 28, 2020 · 2 comments
Labels
stage: ready for work The issue is reproducible and in scope type: typings Issue related to Cypress types (for TypeScript)

Comments

@badeball
Copy link
Contributor

badeball commented Aug 28, 2020

Current behavior:

A HTML-element returned in .then(..) will be wrapped in a JQuery-object by Cypress, but the types doesn't take this into account.

cy.get("div")
  .then($div => $div[0])
  .then($div =>
    $div // The type is erroneously reported as HTMLDivElement.
  );

Desired behavior:

cy.get("div")
  .then($div => $div[0])
  .then($div =>
    $div // $ExpectType JQuery<HTMLDivElement>
  );

Test code to reproduce

Here. Run dtslint types and watch it fail.

Versions

Cypress v5.0.0, Arch Linux.

@sainthkh
Copy link
Contributor

Confirmed that there's an error in types with the code below:

it('t', () => {
  cy.get('div')
  .then(($div) => $div[0])
  .then(($div) => {
    console.log($div) // returns jquery.fn.init

    return $div
  })
})

@sainthkh sainthkh added stage: ready for work The issue is reproducible and in scope type: typings Issue related to Cypress types (for TypeScript) labels Jan 19, 2021
@sainthkh
Copy link
Contributor

Close this in favor of #14875.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
stage: ready for work The issue is reproducible and in scope type: typings Issue related to Cypress types (for TypeScript)
Projects
None yet
Development

No branches or pull requests

2 participants