Current behavior:
The function passed to .then after calling .task must have its parameter typed as undefined when writing the code in Typescript. Ideally, the function's parameter would match the return type of the task. As a workaround, the function's parameter can be explicitly marked as any then dynamically cast to the desired type, but this goes against Typescript best practices.
Desired behavior:
There are probably a few different ways of accomplishing this, but one that comes to mind is:
// In this example, val would have type MyType
cy.task<MyType>("task").then((val) => ...);
Test code to reproduce
// In this example, val is typed as undefined
cy.task("task").then((val) => ...);
Versions
Cypress 4.4.0
Current behavior:
The function passed to
.thenafter calling.taskmust have its parameter typed asundefinedwhen writing the code in Typescript. Ideally, the function's parameter would match the return type of the task. As a workaround, the function's parameter can be explicitly marked asanythen dynamically cast to the desired type, but this goes against Typescript best practices.Desired behavior:
There are probably a few different ways of accomplishing this, but one that comes to mind is:
Test code to reproduce
Versions
Cypress 4.4.0