Skip to content

TS: separate Window type for application under test - #7806

Merged
bahmutov merged 11 commits into
cypress-io:v5.0-releasefrom
sainthkh:pr-6624
Jul 6, 2020
Merged

TS: separate Window type for application under test#7806
bahmutov merged 11 commits into
cypress-io:v5.0-releasefrom
sainthkh:pr-6624

Conversation

@sainthkh

@sainthkh sainthkh commented Jun 25, 2020

Copy link
Copy Markdown
Contributor

User facing changelog

  • Correct type for Window object
  • Provide way to extend Window object type in Application Window.

Breaking change

  • The required minimum TypeScript version has been risen to 3.4.

Additional details

Why was this change necessary?

TypeScript users cannot use valid typescript types.

What is affected by this change?

N/A

Any implementation details to explain?

N/A

How has the user experience changed?

N/A

PR Tasks

@cypress-bot

cypress-bot Bot commented Jun 25, 2020

Copy link
Copy Markdown
Contributor

Thanks for taking the time to open a PR!

@sainthkh sainthkh mentioned this pull request Jun 25, 2020
5 tasks
@sainthkh
sainthkh marked this pull request as ready for review June 25, 2020 02:26
@sainthkh sainthkh added the type: breaking change Requires a new major release version label Jun 25, 2020
@sainthkh
sainthkh marked this pull request as draft June 25, 2020 03:18
@sainthkh
sainthkh marked this pull request as ready for review June 25, 2020 03:26
@flotwig flotwig mentioned this pull request Jun 26, 2020
21 tasks
Comment thread cli/types/cypress.d.ts Outdated
Comment thread cli/types/cypress.d.ts Outdated
Comment thread cli/types/index.d.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why did the entire file change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Interesting. I'll check if there's a change like line-ending.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Line ending was changed at d719f6618e2f893afb66925b4e4611576442591d. Fixed.

@bahmutov bahmutov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we add an e2e test where we have a typescript fixture with ApplicationWindow interface with user property? To confirm the TS passes. Alternatively, and maybe even better is to add a recipe to cypress-example-recipes to show users how to add a property to window and have the types work out of the box.

Comment thread cli/types/index.d.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can a PR to cypress-documentation for page https://on.cypress.io/typescript show the ApplicationWindow example AND minimum TypeScript version needed (3.4) in this case?

Comment thread cli/types/cypress.d.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are there other instances of Chainable<Window> that should also be updated?

Comment thread cli/types/cypress.d.ts Outdated
@brian-mann

Copy link
Copy Markdown
Member

Can we open an issue documenting this fix and why it's necessary. Also per @bahmutov's comments, it seems like there's a bit more work to do on this PR yeah?

@OliverJAsh

Copy link
Copy Markdown
Contributor

I had a clear description in my original PR, but sadly that was closed: #6624

@sainthkh

Copy link
Copy Markdown
Contributor Author

@OliverJAsh

It's recommended to create an issue before submitting a PR in the contributing guide.

If there is not an associated open issue, create an issue using our Issue Template.

Sometimes, ignoring guides can cause unwanted results. (And I also know that it's really tedious to read every contributing guide before contributing.)

Anyway, I opened an issue at #7856.

@sainthkh
sainthkh marked this pull request as draft June 30, 2020 03:06
@sainthkh

sainthkh commented Jun 30, 2020

Copy link
Copy Markdown
Contributor Author

@bahmutov @brian-mann

There are 3 more things to do:

@brian-mann

Copy link
Copy Markdown
Member

@sainthkh proceed ahead - we are trying to release 5.0.0 in the next day or two and want to get this in.

@jennifer-shehane

Copy link
Copy Markdown
Member

@sainthkh cy.window() is not the only command to return the Window, will the other command's definitions be extended? The other commands:

  • cy.go()
  • cy.reload()
  • cy.visit()

@jennifer-shehane

Copy link
Copy Markdown
Member

I've opened a PR for the docs to update the min required version to 3.4+ cypress-io/cypress-documentation#2945

Previously this would type error:

```ts
cy.window().then(window => window.eval('1'));
```
`globalThis` was added in 3.4.
@sainthkh

sainthkh commented Jun 30, 2020

Copy link
Copy Markdown
Contributor Author

It seems that kitchensink needs update after #7782. (CircleCI result link)

@jennifer-shehane
jennifer-shehane requested a review from bahmutov July 6, 2020 09:11
@bahmutov
bahmutov marked this pull request as ready for review July 6, 2020 13:35

@bahmutov bahmutov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is good to go, once merged into v5.0-release we will add testing the recipe cypress-io/cypress-example-recipes#515 PR

@bahmutov bahmutov changed the title Correct Window type. TS: separate Window type for application under test Jul 6, 2020
@bahmutov
bahmutov merged commit 9e754d5 into cypress-io:v5.0-release Jul 6, 2020
@cypress-bot cypress-bot Bot mentioned this pull request Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: breaking change Requires a new major release version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants