diff --git a/cli/types/index.d.ts b/cli/types/index.d.ts index 92cde69ee78d..845cfef1627e 100644 --- a/cli/types/index.d.ts +++ b/cli/types/index.d.ts @@ -652,7 +652,7 @@ declare namespace Cypress { * cy.get('input').should('be.disabled') * cy.get('button').should('be.visible') */ - get(selector: K, options?: Partial): Chainable> + get(selector: K, options?: Partial): Chainable> /** * Get one or more DOM elements by selector. * The querying behavior of this command matches exactly how $(…) works in jQuery. @@ -662,7 +662,7 @@ declare namespace Cypress { * cy.get('ul li:first').should('have.class', 'active') * cy.get('.dropdown-menu').click() */ - get(selector: string, options?: Partial): Chainable> + get(selector: string, options?: Partial): Chainable> /** * Get one or more DOM elements by alias. * @see https://on.cypress.io/get#Alias @@ -673,7 +673,7 @@ declare namespace Cypress { * //later retrieve the todos * cy.get('@todos') */ - get(alias: string, options?: Partial): Chainable + get(alias: string, options?: Partial): Chainable /** * Get a browser cookie by its name. @@ -1622,6 +1622,19 @@ declare namespace Cypress { whitelist: string | string[] | RegExp | ((cookie: any) => boolean) } + /** + * Options that control how a command behaves in the `within` scope + */ + + interface Withinable { + /** + * The subject of the within wrapper. + * + * @default depends on context, null if outside of within wrapper + */ + withinSubject: JQuery | null + } + /** * Options that control how a command is logged in the Reporter */ diff --git a/cli/types/tests/cypress-tests.ts b/cli/types/tests/cypress-tests.ts index e4f7a00b2984..d1718c2b2af4 100644 --- a/cli/types/tests/cypress-tests.ts +++ b/cli/types/tests/cypress-tests.ts @@ -183,6 +183,12 @@ cy.get('body').within({ log: false }, body => { body // $ExpectType JQuery }) +cy.get('body').within(() => { + cy.get('body', { withinSubject: null }).then(body => { + body // $ExpectType JQuery + }) +}) + cy .get('body') .then(() => {