diff --git a/cli/types/cypress.d.ts b/cli/types/cypress.d.ts index 018e7b4b8d..0a0c696ded 100644 --- a/cli/types/cypress.d.ts +++ b/cli/types/cypress.d.ts @@ -1766,7 +1766,7 @@ declare namespace Cypress { * * @see https://on.cypress.io/task */ - task(event: string, arg?: any, options?: Partial): Chainable + task(event: string, arg?: any, options?: Partial): Chainable /** * Enables you to work with the subject yielded from the previous command. diff --git a/cli/types/tests/cypress-tests.ts b/cli/types/tests/cypress-tests.ts index 05625406d9..32a6dad7f4 100644 --- a/cli/types/tests/cypress-tests.ts +++ b/cli/types/tests/cypress-tests.ts @@ -608,3 +608,15 @@ namespace CypressShadowTests { .get('.foo') .find('.bar', {includeShadowDom: true}) } + +namespace CypressTaskTests { + cy.task('foo') // $ExpectType Chainable + cy.task('foo').then((val) => { + val // $ExpectType number + }) + + cy.task('foo') // $ExpectType Chainable + cy.task('foo').then((val) => { + val // $ExpectType unknown + }) +}