fix(types): when user returns any type, then doesn't wrap it with JQuery. (#16756)

This commit is contained in:
Kukhyeon Heo
2021-06-08 06:01:58 +09:00
committed by GitHub
parent e13479f4ca
commit ac4f790d3e
2 changed files with 16 additions and 1 deletions

View File

@@ -1826,6 +1826,12 @@ declare namespace Cypress {
* @see https://on.cypress.io/then
*/
then<S>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => PromiseLike<S>): Chainable<S>
/**
* Enables you to work with the subject yielded from the previous command / promise.
*
* @see https://on.cypress.io/then
*/
then<S extends string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
/**
* Enables you to work with the subject yielded from the previous command / promise.
*
@@ -1843,7 +1849,7 @@ declare namespace Cypress {
*
* @see https://on.cypress.io/then
*/
then<S extends object | any[] | string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
then<S extends any[] | object>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
/**
* Enables you to work with the subject yielded from the previous command / promise.
*

View File

@@ -257,6 +257,15 @@ describe('then', () => {
$p // $ExpectType JQuery<HTMLParagraphElement>
})
})
// https://github.com/cypress-io/cypress/issues/16669
it('any as default', () => {
cy.get('body')
.then(() => ({} as any))
.then(v => {
v // $ExpectType any
})
})
})
cy.wait(['@foo', '@bar'])