Skip to content

Commit

Permalink
Add strong return type to 'invoke' command (cypress-io#4022)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayfieldiv committed Aug 2, 2019
1 parent 7e2ca83 commit dee9485
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions cli/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,14 +811,10 @@ declare namespace Cypress {

/**
* Invoke a function on the previously yielded subject.
* This isn't possible to strongly type without generic override yet.
* If called on an object you can do this instead: `.then(s => s.show())`.
* If called on an array you can do this instead: `.each(s => s.show())`.
* From there the subject will be properly typed.
*
* @see https://on.cypress.io/invoke
*/
invoke(functionName: keyof Subject, ...args: any[]): Chainable<Subject> // don't have a way to express return types yet
invoke<K extends keyof Subject>(functionName: K, ...args: any[]): Chainable<ReturnType<Subject[K]>>

/**
* Get a property’s value on the previously yielded subject.
Expand Down

0 comments on commit dee9485

Please sign in to comment.