diff --git a/cli/types/cypress.d.ts b/cli/types/cypress.d.ts index 131e43bbda4a..fb603d6d3ccb 100644 --- a/cli/types/cypress.d.ts +++ b/cli/types/cypress.d.ts @@ -262,7 +262,7 @@ declare namespace Cypress { * Currently executing test runnable instance. */ currentTest: { - title: string, + title: string titlePath: string[] } @@ -402,9 +402,9 @@ declare namespace Cypress { * @see https://on.cypress.io/api/commands */ Commands: { - add(name: string, fn: (...args: any[]) => CanReturnChainable): void - add(name: string, options: CommandOptions, fn: (...args: any[]) => CanReturnChainable): void - overwrite(name: string, fn: (...args: any[]) => CanReturnChainable): void + add(name: T, fn: Chainable[T]): void + add(name: T, options: CommandOptions, fn: Chainable[T]): void + overwrite(name: T, fn: Chainable[T]): void } /** diff --git a/cli/types/tests/cypress-tests.ts b/cli/types/tests/cypress-tests.ts index ed13bc580196..910d52aeccd5 100644 --- a/cli/types/tests/cypress-tests.ts +++ b/cli/types/tests/cypress-tests.ts @@ -62,17 +62,31 @@ namespace CypressIsCyTests { }) } +declare namespace Cypress { + interface Chainable { + newCommand: (arg: string) => void + } +} + namespace CypressCommandsTests { - Cypress.Commands.add('newCommand', () => { + Cypress.Commands.add('newCommand', (arg) => { + // $ExpectType string + arg return }) - Cypress.Commands.add('newCommand', { prevSubject: true }, () => { + Cypress.Commands.add('newCommand', { prevSubject: true }, (arg) => { + // $ExpectType string + arg return }) - Cypress.Commands.add('newCommand', () => { + Cypress.Commands.add('newCommand', (arg) => { + // $ExpectType string + arg return new Promise((resolve) => {}) }) - Cypress.Commands.overwrite('newCommand', () => { + Cypress.Commands.overwrite('newCommand', (arg) => { + // $ExpectType string + arg return }) }