Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support? :) #297

Open
dbarrientostk opened this issue Jun 13, 2024 · 1 comment
Open

Typescript support? :) #297

dbarrientostk opened this issue Jun 13, 2024 · 1 comment

Comments

@dbarrientostk
Copy link

I use typescript in my cypress project and I have been facing some issues to scroll if the element is not visible, so cypress recurse looks great :)
I hope that you can add support for typescript.

@joaopslins
Copy link

joaopslins commented Oct 31, 2024

That would be great! Just stumbled upon this while converting my Cypress app from JS to TS.

For whoever needs this in the future, I managed to get some type support by doing:

// cypress.d.ts
declare namespace Cypress {
  type RecurseOptions<T> = import('cypress-recurse').RecurseOptions<T>;

  interface Chainable {
    recurse<T>(
      commandsFn: () => Chainable<T>,
      checkFn: (
        x: T,
        reducedValue?: any,
      ) => boolean | void | Chai.Assertion,
      options?: Partial<RecurseOptions<T>>,
    ): Chainable<T>
  }
}

I got the type definition from here:

export function recurse<T>(

And for the dynamic import file, I got from here:
https://stackoverflow.com/questions/39040108/import-class-in-definition-file-d-ts

Maybe there's a way to import the function definition directly, but this solution worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants