fix: cy.then shows wrong type when collection of HTMLElement's is provided (#15869)

This commit is contained in:
Jonas Amundsen
2021-04-22 20:22:09 +02:00
committed by GitHub
parent a7028352c6
commit d4e48858fb
2 changed files with 21 additions and 0 deletions
+12
View File
@@ -1826,6 +1826,12 @@ declare namespace Cypress {
* @see https://on.cypress.io/then
*/
then<S extends HTMLElement>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S>>
/**
* Enables you to work with the subject yielded from the previous command / promise.
*
* @see https://on.cypress.io/then
*/
then<S extends ArrayLike<HTMLElement>>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S extends ArrayLike<infer T> ? T : never>>
/**
* Enables you to work with the subject yielded from the previous command / promise.
*
@@ -1844,6 +1850,12 @@ declare namespace Cypress {
* @see https://on.cypress.io/then
*/
then<S extends HTMLElement>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S>>
/**
* Enables you to work with the subject yielded from the previous command / promise.
*
* @see https://on.cypress.io/then
*/
then<S extends ArrayLike<HTMLElement>>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S extends ArrayLike<infer T> ? T : never>>
/**
* Enables you to work with the subject yielded from the previous command / promise.
*
+9
View File
@@ -239,6 +239,15 @@ describe('then', () => {
$div // $ExpectType JQuery<HTMLDivElement>
})
cy.get('div')
.then(($div) => {
$div // $ExpectType JQuery<HTMLDivElement>
return [$div[0]]
})
.then(($div) => {
$div // $ExpectType JQuery<HTMLDivElement>
})
cy.get('p')
.then(($p) => {
$p // $ExpectType JQuery<HTMLParagraphElement>