-
Notifications
You must be signed in to change notification settings - Fork 25
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
Problem with TypeScript signature #477
Comments
Can you please elaborate more, please? With some eventual IDE's screenshots and/or shiki twoslash reported type? The |
Your function returns a Chainable object whose value is the one returned by Currently the function is typed to return Take this example (written from memory) : // assume a task "myTask" which return the following type
type MyTaskReturn {
uid: string;
}
cy.get('#input1')
// get value of input1
.its('value')
// execute the task to make somthing with the value
.waitUntil((value) => cy.task<MyTaskReturn>('myTask', value))
// write the task result in another input
.then(result=> {
cy.get('#input2').type(result.uid); // ERROR: "uid" is not defined on type string
}); Here I don't see how this couldn't be changed. I can provide tomorrow a real example, but it is basically this. |
Real world example : here waitUntil is not chained from another query, as such the result value is not typed at all. cy.waitUntil(() => {
return cy.task<string[]>('listFiles', {
dir: Cypress.config('downloadsFolder'),
name: name,
});
})
.then((results) => {
if (results.length === 1) { // ERROR 'results' is possibly undefined
....
}
}); (the implementation of waitUntil garantees that the result cannot be undefined) If I force the type with And If I edit your d.ts to return |
BREAKING CHANGE: TypeScript tests could now throw because of operations made on the value returned by `checkFunction` (passed to cy.waitUntil). The type was previously `undefined` while now reflects the type returned by `checkFunction`. fix #477
* chore: update to Node.js 20 * fix: fix waitUntil chained value type BREAKING CHANGE: TypeScript tests could now throw because of operations made on the value returned by `checkFunction` (passed to cy.waitUntil). The type was previously `undefined` while now reflecting the type returned by `checkFunction`. fix #477
🎉 This issue has been resolved in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
You were right, thank you so much for reporting it ❤️ |
@all-contributors please add @mistic100 for bug |
I've put up a pull request to add @mistic100! 🎉 |
Hi,
I think there is an error in the return type of the function.
Because
the function actually returns
Chainable<ReturnType>
but currently it is declared asChainable<Subject>
thanks.
The text was updated successfully, but these errors were encountered: