What would you like?
I'd like to be able to reference these Cypress and Chai globals as properties of the global object (which they are) in TypeScript without the TypeScript compiler reporting an error.
The current type declarations prohibit this by incorrectly declaring that the objects in question are held in local variables of the global scope rather than in properties of the global object.
For example, the TypeScript compiler currently accepts these statements:
const browserVersion = Cypress.browser.version;
cy.mount(AppComponent);
assert("foo" !== "bar", "foo is not bar");
expect(true).not.to.be.false;
But, misguided by inaccurate type declarations, the TypeScript compiler issues an error for each of these statements:
const browserVersion = window.Cypress.browser.version;
window.cy.mount(AppComponent);
window.assert("foo" !== "bar", "foo is not bar");
window.expect(true).not.to.be.false;
const browserVersion = globalThis.Cypress.browser.version;
globalThis.cy.mount(AppComponent);
globalThis.assert("foo" !== "bar", "foo is not bar");
globalThis.expect(true).not.to.be.false;
Why is this needed?
Resolving this issue entails swapping the use of const for var in type declarations in cli/types/cypress-expect.d.ts and cli/types/cypress-global-vars.d.ts.
This small change would accommodate a coding style convention that demands that values in properties of the global object be accessed via the globalThis property of that object to enhance clarity regarding the origin of the values as globals as opposed to values defined in and imported from modules.
The change would have no impact on the TypeScript compiler's acceptance of code that uses Cypress globals without that convention, which is the majority of such code.
Other
No response
What would you like?
I'd like to be able to reference these Cypress and Chai globals as properties of the global object (which they are) in TypeScript without the TypeScript compiler reporting an error.
The current type declarations prohibit this by incorrectly declaring that the objects in question are held in local variables of the global scope rather than in properties of the global object.
For example, the TypeScript compiler currently accepts these statements:
But, misguided by inaccurate type declarations, the TypeScript compiler issues an error for each of these statements:
Why is this needed?
Resolving this issue entails swapping the use of
constforvarin type declarations in cli/types/cypress-expect.d.ts and cli/types/cypress-global-vars.d.ts.This small change would accommodate a coding style convention that demands that values in properties of the global object be accessed via the globalThis property of that object to enhance clarity regarding the origin of the values as globals as opposed to values defined in and imported from modules.
The change would have no impact on the TypeScript compiler's acceptance of code that uses Cypress globals without that convention, which is the majority of such code.
Other
No response