Skip to content
Advertisement

Cypress error while migrating from js to ts (ts2345) (ts2339)

Currently trying to convert a cypress(10) project from js to ts.

My Custom commands don’t seem to be working, i get the following error while defining the custom command(the name of the custom command is underlined in red):

JavaScript

My Custom command code:

JavaScript

When using those commands (*.ts file now after renaming from *.js) i also get an error:

JavaScript

What do I need to do to fix this?

Thamks in advance!

Ps: Problem seems to be with the custom command, because i can sill use the custom commands defined in a js file in a ts testfile(*.cy.ts)

Custom command is defined in: NotifModules.ts

Documentation is defined in: NotifModules.d.ts

TestFile is called: Notifications.cy.ts

/cypress/tsconfig.json:

JavaScript

/cypress.config.ts:

JavaScript

Advertisement

Answer

I have found the solution to my question: I had my *.d.ts files located inside the cypress/support folder, right next to the *.ts files with all the custom commands. Moving those outside(!) the “support”-folder and into another one called “definitionFiles” (for example) worked beautifully!

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement