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

Custom command types

Open rndmerle opened this issue 4 years ago • 3 comments

Hi and thanks for this package, this is coming in handy. Any way to declare types for custom commands and chai-subsets ? Extending Cypress.Chainable and Cypress.Chainer interfaces the classic way in a .d.ts doesn't seem to work.

rndmerle avatar Sep 30 '21 08:09 rndmerle

Well, actually with a .ts test file instead of .js is working alright.

rndmerle avatar Sep 30 '21 09:09 rndmerle

@rndmerle Could you explain what you did? I'm having some issues.

brianbento avatar Oct 27 '21 21:10 brianbento

Well nothing fancy.

test/dts/cypress-commands.d.ts :

declare namespace Cypress {
  interface Chainable {
    $whatever(): Chainable<any>
  }
}

tsconfig.json :

"typeRoots": ["node_modules/@types", "test/__dts__"],
"include": [
  // ... other source directories
  "test/**/*.ts",
]

If it doesn't help, maybe could you provide a minimal repo reproducing the issue?

rndmerle avatar Nov 02 '21 11:11 rndmerle