Description
Current behavior
I am getting a Typescript error for those cases:
- Cypress.Command.add() with { prevSubject: true }
Cypress.Commands.add("newCommand", { prevSubject: true }, (element) => {});
In the above example, element
is of type unknown
but instead, it should be JQuery<HTMLElement>
, this could be handled by passing the generics values like that:
Cypress.Commands.add<"newCommand","element">("newCommand", { prevSubject: true }, (element) => {});
But I think passing true
to the prevSubject
option, the element type should be JQuery<HTMLElement>
by itself.
- Cypress.Command.add() with {prevSubject: "element" }
Cypress.Commands.add("newCommand", { prevSubject: "element" }, (element) => {
element.selector
});
I am trying to access the selector
property, but I got a typescript error that it does not exist on type JQuery<HTMLElement>
Desired behavior
No typescript error should be printed, as the selector
property does exist in the element
object.
Test code to reproduce
https://github.com/atarek12/cypress/blob/fix-prevSubject-types/cli/types/tests/cypress-tests.ts#L87
Cypress Version
9.5.0
Other
No response
Metadata
Metadata
Assignees
Labels
No labels