I am implementing a custom Cypress command in TypeScript:
// support/commands.ts
const login = () => {
console.log(\'Logging in...\');
};
Cypress.Command
I fixed it by adding index.d.ts file in my commands folder. In this file I added something like this:
import { MyCustomType } from '../Types';
declare global {
namespace Cypress {
interface Chainable {
login(): Chainable;
}
}
}
If You don't import or export anything, just omit global namespace declaration:
declare namespace Cypress {
interface Chainable {
login(): Chainable;
}
}
Keep in mind that it won't work with Typesciprt < 2.3, becuase default generics type has to be supported.