question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Argument of type '() => void' is not assignable to parameter of type '() => Chainable<any>'.

See original GitHub issue

Current behavior

With the upgrade to v9, Cypress is reporting the following error when adding a custom method:

Argument of type '() => void' is not assignable to parameter of type '() => Chainable<any>'.

Desired behavior

According to the documentation, no other code should be needed to make this work.

Thus I believe that void should be a valid type to be supported.

Test code to reproduce

Cypress.Commands.add('login', () => {
  // do something
})

Cypress Version

9.0.0

Other

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
LuisValgoicommented, Mar 30, 2022

Same thing here…

image

Screen Shot 2022-03-30 at 13 34 57

8reactions
mleblancbpacommented, May 26, 2022

If anybody else falls here to find out how to get rid of typescript error in declaring commands, you have to wrap your declare namespace Cypress bloc in a declare global { ... } block like so:

declare global {
  namespace Cypress {
    interface Chainable {
      login(): void;
    }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Argument type 'void' is not assignable to parameter of type
The error "Argument of type 'void' is not assignable to parameter of type" occurs when we forget to return from a function and...
Read more >
TypeScript error: Type 'void' is not assignable to ...
It means that the callback function you passed to this.dataStore.data.find should return a boolean and have 3 parameters, two of which can ...
Read more >
Incorrect "Type void is not assignable to ...
If I add a parameter to the function (like so: e => scriptEvent(); ), and do e. , WebStorm suggests function functions &...
Read more >
How to fix error TS2345: Argument of type 'void' is not ...
This was the error I was getting: error TS2345: Argument of type 'void' is not assignable to parameter of type 'TimerHandler'.
Read more >
type 'void' is not assignable to type 'reactelement<any, any>
In your definition private _noop: () => {}; _noop is typed as a function returning an object. When you assign it as this._noop...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found