diff --git a/cli/types/cypress.d.ts b/cli/types/cypress.d.ts index 65f51f96722e..e10198993322 100644 --- a/cli/types/cypress.d.ts +++ b/cli/types/cypress.d.ts @@ -1755,7 +1755,7 @@ declare namespace Cypress { * cy.press(Cypress.Keyboard.Keys.TAB) // dispatches a keydown and press event to the browser, followed by a keyup event. * @see https://on.cypress.io/press */ - press(key: typeof Cypress.Keyboard.Keys[keyof typeof Cypress.Keyboard.Keys], options?: Partial): Chainable + press(key: typeof Cypress.Keyboard.Keys[keyof typeof Cypress.Keyboard.Keys], options?: Partial): Chainable /** * Get the immediately preceding sibling of each element in a set of the elements. diff --git a/packages/driver/src/cy/commands/actions/press.ts b/packages/driver/src/cy/commands/actions/press.ts index 7c4110f35de8..cb0be4c484fa 100644 --- a/packages/driver/src/cy/commands/actions/press.ts +++ b/packages/driver/src/cy/commands/actions/press.ts @@ -7,11 +7,11 @@ import $errUtils from '../../../cypress/error_utils' import $utils from '../../../cypress/utils' export interface PressCommand { - (key: KeyPressSupportedKeys, userOptions?: Partial & Partial): void + (key: KeyPressSupportedKeys, userOptions?: Partial & Partial): Promise } export default function (Commands: Cypress.Commands, Cypress: Cypress.Cypress, cy: $Cy, state: StateFunc, config: any) { - async function pressCommand (key: KeyPressSupportedKeys, userOptions?: Partial & Partial) { + const press: PressCommand = async function pressCommand (key: KeyPressSupportedKeys, userOptions?: Partial & Partial) { const options: Cypress.Loggable & Partial = defaults({}, userOptions, { log: true, }) @@ -36,7 +36,7 @@ export default function (Commands: Cypress.Commands, Cypress: Cypress.Cypress, c // throwErrByPath always throws, but there's no way to indicate that // code beyond this point is unreachable to typescript / linters - return null + return } if (Cypress.browser.family === 'webkit') { @@ -47,7 +47,7 @@ export default function (Commands: Cypress.Commands, Cypress: Cypress.Cypress, c }, }) - return null + return } if (Cypress.browser.name === 'firefox' && Number(Cypress.browser.majorVersion) < 135) { @@ -72,10 +72,10 @@ export default function (Commands: Cypress.Commands, Cypress: Cypress.Cypress, c $errUtils.throwErr(err, { onFail: log }) } - return null + return } return Commands.addAll({ - press: pressCommand, + press, }) }