-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Enhance typings for cy.intercept and cy.wait #29507
Labels
type: typings
Issue related to Cypress types (for TypeScript)
Comments
2 tasks
scottmcginness
added a commit
to scottmcginness/cypress
that referenced
this issue
May 13, 2024
scottmcginness
added a commit
to scottmcginness/cypress
that referenced
this issue
May 13, 2024
…s-io#29507) The nested types were apparently not supported (as written) before TypeScript ~4.1.Remove them in favour of just using `Interception<any, any>` in this overload of `wait`.
scottmcginness
added a commit
to scottmcginness/cypress
that referenced
this issue
May 25, 2024
jennifer-shehane
added a commit
that referenced
this issue
Jun 3, 2024
…#29508) * misc: Add generic types to net-stubbing for use in intercept and wait * misc: Add changelog entry (#29507) * misc: Revert to `any` for Interception type of multiple waits (#29507) The nested types were apparently not supported (as written) before TypeScript ~4.1.Remove them in favour of just using `Interception<any, any>` in this overload of `wait`. * misc: Move changelog entry (#29507) --------- Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com> Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
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.
What would you like?
In order to have request and response types for the
body
property in calls tocy.intercept
andcy.wait
, I'd like to be able to specify generics for these, so that I don't have to useany
in the callbacks.Specifically:
and
Why is this needed?
While looking at converting our project to TypeScript, I was surprised that we'd have to either:
any
for thebody
parameter in all callbacks ofintercept
andwait
which still requires
as
if we want to keep full type safety.This feels especially awkward because we have wrapped some
wait
calls to their own methods:Instead. with the proposal above, it is marginally easier and less error prone to write:
We do have these types (
CustomRequest
andCustomResponse
as examples) already defined, so would be good if we can use them easily everywhere.Other
I have a fork that puts a type on the core
BaseMessage
interface, forbody
. This caused all the related types to have required updates to their types (i.e. made generic too).I might have missed a better way to think about or do this.
The text was updated successfully, but these errors were encountered: