Skip to content
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

fix: types for Cypress.Commands.add (#20376) #20377

Merged
merged 10 commits into from Apr 15, 2022

Conversation

atarek12
Copy link
Contributor

@atarek12 atarek12 commented Feb 27, 2022

User facing changelog

Fix Cypress.Command.add() TypeScript types. Fixes #20376

  • Infer the subject type to be an element while using prevSubject: true option
  • Adding property selector to the subject while using prevSubject: true | "element" option

Additional details

This change fixes typescript errors while using the Cypress.Command.add() with { prevSubject: true } or { prevSubject: "element" }

How has the user experience changed?

No typescript error while trying to access the selector.

Cypress.Commands.add("newCommand", { prevSubject: "element" }, (element) => {
  element.selector // no typescript error
});

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?
  • Have new configuration options been added to the cypress.schema.json?

@atarek12 atarek12 requested a review from a team as a code owner February 27, 2022 00:12
@atarek12 atarek12 requested review from jennifer-shehane and removed request for a team February 27, 2022 00:12
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 27, 2022

Thanks for taking the time to open a PR!

@CLAassistant
Copy link

CLAassistant commented Feb 27, 2022

CLA assistant check
All committers have signed the CLA.

@atarek12 atarek12 changed the title fix types for Cypress.Commands.add fix: types for Cypress.Commands.add (#20376) Feb 27, 2022
@atarek12 atarek12 force-pushed the fix-prevSubject-types branch 2 times, most recently from 97456df to 87091cd Compare February 27, 2022 07:19
@jennifer-shehane
Copy link
Member

@atarek12 Thanks for opening this PR. Our team will pick this up as soon as possible.

cli/types/cypress.d.ts Outdated Show resolved Hide resolved
@jennifer-shehane jennifer-shehane removed their request for review April 7, 2022 15:06
Copy link
Contributor

@BlueWinds BlueWinds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me; Just rerunning some of our flaky tests to get everything green before merging.

@flotwig flotwig merged commit 92d9425 into cypress-io:develop Apr 15, 2022
flotwig added a commit that referenced this pull request Apr 15, 2022
@flotwig
Copy link
Contributor

flotwig commented Apr 15, 2022

@atarek12 This PR caused a type failure when merged in and was reverted, can you please re-open this PR against the latest develop and take a look? Once it's passing we can merge it again.

Failure: app.circleci.com/pipelines/github/cypress-io/cypress/36421/workflows/c59bf671-cfde-4305-83b3-d46fbc95c0fc/jobs/1458838

tbiethman added a commit that referenced this pull request Apr 15, 2022
@atarek12 atarek12 mentioned this pull request Apr 15, 2022
5 tasks
@atarek12
Copy link
Contributor Author

@flotwig you can find a new opened PR here

tgriesser added a commit that referenced this pull request Apr 20, 2022
…e-config

* 10.0-release:
  chore: Move component-index generation to scaffold-config package (#21090)
  fix: label text should be clickable to toggle snapshot highlight (#21122)
  feat: add next preset to webpack-dev-server-fresh (#21069)
  chore: add dev-servers as deps to server to be included in the binary (#21142)
  fix: do not highlight preExtension if selected option is renameFolder (#21121)
  fix(unify): Remove 'Reconfigure' dropdown from Testing Type chooser (#21063)
  feat(unify): launchpad header breadcrumbs and reusable tooltip component (#20648)
  test: add windows-test-kitchensink job (#20847)
  fix: aut centering and height calculation (#21019)
  chore: fix tests that fail on windows (#21055)
  fix: running a new test after already having run tests (#21087)
  fix: ct project setup framework keys for next and nuxt (#21116)
  fix: remove MountReturn from scaffolded ct support file (#21119)
  fix: do not scaffold fixtures if folder exist (#21078)
  fix: revert "fix: types for Cypress.Commands.add (#20376)" (#21104)
  chore: Update Chrome (stable) to 100.0.4896.127 and Chrome (beta) to 101.0.4951.34 (#21083)
  fix: types for Cypress.Commands.add (#20376) (#20377)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants