cypress-recurse icon indicating copy to clipboard operation
cypress-recurse copied to clipboard

Hmm, Promise<never> when using an arrow function?

Open bahmutov opened this issue 3 years ago • 12 comments

recurse(
   () => cy.get('#output').invoke('text'),
   (text) => text === 'Surprise!',

TypeScript check complains about Promise<never>?

Screen Shot 2022-03-01 at 14 08 40

Making a full function seems to solve a problem, but why...

function getText() {
  return cy.get('#output').invoke('text')
}

recurse(getText, (text) => text === 'Surprise!')
Screen Shot 2022-03-01 at 14 10 33

cc @Stumblinbear

bahmutov avatar Mar 01 '22 19:03 bahmutov

Ahh, I see what happened. I was having issues getting JSDoc to be happy by not using TS overloading, but that seems to be causing issues. Let me quick fix that.

Stumblinbear avatar Mar 01 '22 19:03 Stumblinbear

Fixed by #78

Stumblinbear avatar Mar 01 '22 19:03 Stumblinbear

:tada: This issue has been resolved in version 1.14.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Mar 01 '22 19:03 github-actions[bot]

Need to reopen, since still shows the same problem

Screen Shot 2022-03-07 at 08 01 55

bahmutov avatar Mar 07 '22 13:03 bahmutov

@Stumblinbear ^^^

bahmutov avatar Mar 07 '22 13:03 bahmutov

Got a code sample to reproduce?

Stumblinbear avatar Mar 07 '22 14:03 Stumblinbear

Yup it is the basic-spec in this repo - I had to add ts-ignore in a couple of places. Run lint script after removing the ts-ignore

Sent from my iPhone

On Mar 7, 2022, at 09:08, Trevin Miller @.***> wrote:

 Got a code sample to reproduce?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.

bahmutov avatar Mar 07 '22 14:03 bahmutov

I'm not getting any errors, even without the ts-ignores

Stumblinbear avatar Mar 07 '22 14:03 Stumblinbear

Re-installed, tried, the same thing :(

Screen Shot 2022-03-07 at 11 11 54

bahmutov avatar Mar 07 '22 16:03 bahmutov

Try pulling my repo and see if you get the same thing. What's the return type of whatever value is in the recursive commandsFn lambda?

Stumblinbear avatar Mar 07 '22 16:03 Stumblinbear

same, thing, for some reason it thinks cy.task('randomNumber') is Promise<never>

Screen Shot 2022-03-11 at 08 43 11

bahmutov avatar Mar 11 '22 13:03 bahmutov

Oh, it's through a task. That seems more like an issue with task than the types here. Is there a definition for defining the return type of 'randomNumber'?

Stumblinbear avatar Mar 11 '22 22:03 Stumblinbear