-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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.Commands.add
type doesn't take into account prevSubject
to define the type of the custom command
#18940
Comments
Cypress.Commands.add
type doesn't take into account prevSubject
to define the type of the functionCypress.Commands.add
type doesn't take into account prevSubject
to define the type of the custom command
We have the same issue 😢 |
same issue here, problem is both for dual and child custom commands |
Same here, introduced with this PR, like OP said wrong tests. |
Also this test for optional subject should be added: Cypress.Commands.add('newCommand', { prevSubject: 'optional' }, (subject, arg) => {
// $ExpectType string
arg
return
}) |
Same issue: This was working in Cypress < 9.0.0
It is not working in Cypress 9.0.0. |
The code for this is done in cypress-io/cypress#19003, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
subject
andvalue
are inferred asany
asprevSubject
isn't taken into account and TS expect a single paramIf
value
is removed, the first param becomesstring
which is wrongThe same problem applies to child commands
Desired behavior
Types should take into consideration
prevSubject
and use it into a conditional to provide correct typingsThere may be other edge cases with
element
|document
|window
Test code to reproduce
https://github.com/cypress-io/cypress/pull/17496/files#diff-facdf706a5238380b5e97c040bc1a5f5cb89e3116f878754dd7fb4e693787715R77
This test is wrong, it should be
Cypress Version
9.0.0
Other
No response
The text was updated successfully, but these errors were encountered: