mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-09 08:40:32 -06:00
feat: Update types for Cypress.Chainable.task to allow for parameterizing the task return type (#8753)
Co-authored-by: Zach Bloomquist <github@chary.us>
This commit is contained in:
2
cli/types/cypress.d.ts
vendored
2
cli/types/cypress.d.ts
vendored
@@ -1766,7 +1766,7 @@ declare namespace Cypress {
|
||||
*
|
||||
* @see https://on.cypress.io/task
|
||||
*/
|
||||
task(event: string, arg?: any, options?: Partial<Loggable & Timeoutable>): Chainable<Subject>
|
||||
task<S = unknown>(event: string, arg?: any, options?: Partial<Loggable & Timeoutable>): Chainable<S>
|
||||
|
||||
/**
|
||||
* Enables you to work with the subject yielded from the previous command.
|
||||
|
||||
@@ -608,3 +608,15 @@ namespace CypressShadowTests {
|
||||
.get('.foo')
|
||||
.find('.bar', {includeShadowDom: true})
|
||||
}
|
||||
|
||||
namespace CypressTaskTests {
|
||||
cy.task<number>('foo') // $ExpectType Chainable<number>
|
||||
cy.task<number>('foo').then((val) => {
|
||||
val // $ExpectType number
|
||||
})
|
||||
|
||||
cy.task('foo') // $ExpectType Chainable<unknown>
|
||||
cy.task('foo').then((val) => {
|
||||
val // $ExpectType unknown
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user