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

Cypress.Buffer has the wrong TypeScript type #20542

Closed
dantman opened this issue Mar 9, 2022 · 3 comments · Fixed by #20553
Closed

Cypress.Buffer has the wrong TypeScript type #20542

dantman opened this issue Mar 9, 2022 · 3 comments · Fixed by #20553
Labels
type: typings Issue related to Cypress types (for TypeScript)

Comments

@dantman
Copy link
Contributor

dantman commented Mar 9, 2022

Current behavior

The TypeScript type for Cypress.Buffer is currently mapped to the type of a Buffer instance, not the static/constructor.

As a result trying to use Cypress.Buffer.from gives the TypeScript error:
Property 'from' does not exist on type 'Buffer'. Did you mean to access the static member 'Buffer.from' instead?

Desired behavior

Using Cypress.Buffer.from should not result in a TypeScript error.

Test code to reproduce

Cypress.Buffer.from('Test');

Cypress Version

9.5.1

Other

No response

@jennifer-shehane
Copy link
Member

We'd welcome a PR to fix this.

@jennifer-shehane jennifer-shehane added the type: typings Issue related to Cypress types (for TypeScript) label Mar 9, 2022
dantman added a commit to dantman/cypress that referenced this issue Mar 10, 2022
BufferType refers to an instance of Buffer instead of the Buffer type itself. As a result `Cypress.Buffer.from('asdf')` is considered invalid code.

To get the Buffer class itself rather than the type for an instance of the class, you need to use the typeof keyword.

Fixes cypress-io#20542
@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Mar 10, 2022
dantman added a commit to dantman/cypress that referenced this issue Mar 10, 2022
BufferType refers to an instance of Buffer instead of the Buffer type itself. As a result `Cypress.Buffer.from('asdf')` is considered invalid code.

To get the Buffer class itself rather than the type for an instance of the class, you need to use the typeof keyword.

Fixes cypress-io#20542
@cypress-bot cypress-bot bot added stage: waiting and removed stage: needs review The PR code is done & tested, needs review labels Mar 14, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 23, 2022

The code for this is done in cypress-io/cypress#20553, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 28, 2022

Released in 9.5.3.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v9.5.3, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Mar 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: typings Issue related to Cypress types (for TypeScript)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants