-
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
Correct window type #6624
Correct window type #6624
Conversation
Previously this would type error: ```ts cy.window().then(window => window.eval('1')); ```
Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.
PR Review ChecklistIf any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'. User Experience
Functionality
Maintainability
Quality
Internal
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OliverJAsh There's an error in the TS Lint, additionally, can you add a test for this? In the appropriate file under cli/types/tests
Error: /root/cypress/cli/types/index.d.ts:1967:82
ERROR: 1967:82 expect Compile error in [email protected] but not in [email protected].
Fix with a comment '// TypeScript Version: 3.4' just under the header.
Cannot find name 'globalThis'.
at /root/cypress/node_modules/dtslint/bin/index.js:190:19
at Generator.next (<anonymous>)
at fulfilled (/root/cypress/node_modules/dtslint/bin/index.js:5:58)
@OliverJAsh Regarding the issue we talked about — here's a suggestion for how we can really get the right If my suggestion falls outside the scope of this pull request, please let me know — I can open a separate issue or a pull request instead. Problem When you run a test with Cypress, there are two
These are different Solution Allow users to define global variables separately. In interface ApplicationWindow {} Change the definition for window(options?: Partial<Loggable & Timeoutable>): Chainable<Window & typeof globalThis & ApplicationWindow> Usage The users can now define properties that exist on the yielded declare global {
namespace Cypress {
interface ApplicationWindow {
__FOO__?: string;
}
}
} |
@@ -4,7 +4,7 @@ | |||
// Mike Woudenberg <https://github.com/mikewoudenberg> | |||
// Robbert van Markus <https://github.com/rvanmarkus> | |||
// Nicholas Boll <https://github.com/nicholasboll> | |||
// TypeScript Version: 2.9 | |||
// TypeScript Version: 3.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a spooky/major change? Are we sure this isn't going to impact folks downstream maybe using earlier TS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's needed to support globalThis
. It may well affect your users, so you might want to put this PR on hold until more of your users are on 3.4 or above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've run into this before, so this is not the first time this has been suggested. #4950 (review)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we just accepted a pull to move to 3.0, I'm guessing that's going to be a conflict -- curious if these changes work at that level (3.0)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.4 is the minimum version if we want to use globalThis
Dismissing my previous reviews to allow for others to review actual code changes.
@OliverJAsh Can you fix the conflicts? We just made some TS changes that we merged in. |
@jennifer-shehane Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the TypeScript breaking changes list, some vendor-specific types are removed in TypeScript 3.1.
I think it's a better idea to apply this PR to Cypress 5.0. It can potentially break users' types.
We're looking to release 5.0, with breaking changes. Is it possible to reevaluate this PR? |
@jennifer-shehane I will. |
Close in favor of #7806 |
Previously this would type error:
(
window
should have typeWindow & typeof globalThis
.)You may want to fix other instances of
Chainable<Window>
as well.User facing changelog
Additional details
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?