-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Typings for cy.task when chaining with .then #7136
Labels
type: typings
Issue related to Cypress types (for TypeScript)
Comments
jennifer-shehane
added
the
type: typings
Issue related to Cypress types (for TypeScript)
label
Apr 27, 2020
In the mean time you can overwrite the type to: /// <reference types="cypress" />
declare global {
namespace Cypress {
interface Chainable<Subject = any> {
task<T>(event: string, arg?: any, options?: Partial<Loggable & Timeoutable>): Chainable<T>
}
}
}
export {} |
cypress-bot
bot
added
stage: work in progress
stage: needs review
The PR code is done & tested, needs review
and removed
stage: proposal 💡
No work has been done of this issue
stage: work in progress
stage: needs review
The PR code is done & tested, needs review
labels
Oct 6, 2020
cypress-bot
bot
added
stage: needs review
The PR code is done & tested, needs review
and removed
stage: work in progress
labels
Oct 13, 2020
cypress-bot
bot
added
stage: pending release
and removed
stage: needs review
The PR code is done & tested, needs review
labels
Oct 28, 2020
The code for this is done in cypress-io/cypress#8753, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Current behavior:
The function passed to
.then
after calling.task
must have its parameter typed asundefined
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 asany
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:
Test code to reproduce
Versions
Cypress 4.4.0
The text was updated successfully, but these errors were encountered: