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' built-in lodash types are incompatible with TypeScript 5.2+. #29519

Open
threehams opened this issue May 14, 2024 · 0 comments
Open
Labels
stage: needs investigating Someone from Cypress needs to look at this type: typings Issue related to Cypress types (for TypeScript)

Comments

@threehams
Copy link

threehams commented May 14, 2024

Current behavior

Cypress' contains the following line in node_modules/cypress/types/lodash.d.ts, which is created by the cypress package somehow (it is not a normal node_modules dependency, and not part of source):

// Backward compatibility with --target es5
declare global {
    // tslint:disable-next-line:no-empty-interface
    interface Set<T> { }
    // tslint:disable-next-line:no-empty-interface
    interface Map<K, V> { }
    // tslint:disable-next-line:no-empty-interface
    interface WeakSet<T> { }
    // tslint:disable-next-line:no-empty-interface
    interface WeakMap<K extends object, V> { }
}

This is based on lodash types 4.14.168, last updated a little over 3 years ago.

When TypeScript 5.2+ is set up with "lib": ["esnext"], the following error occurs when running tsc:

node_modules/cypress/types/lodash/index.d.ts:45:15 - error TS2428: All declarations of 'WeakMap' must have identical type parameters.

45     interface WeakMap<K extends object, V> { }
                 ~~~~~~~

node_modules/typescript/lib/lib.es2015.collection.d.ts:63:11 - error TS2428: All declarations of 'WeakMap' must have identical type parameters.

63 interface WeakMap<K extends WeakKey, V> {
             ~~~~~~~

node_modules/typescript/lib/lib.es2015.iterable.d.ts:162:11 - error TS2428: All declarations of 'WeakMap' must have identical type parameters.

162 interface WeakMap<K extends WeakKey, V> { }
              ~~~~~~~

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:140:11 - error TS2428: All declarations of 'WeakMap' must have identical type parameters.

140 interface WeakMap<K extends WeakKey, V> {
              ~~~~~~~

Desired behavior

Cypress can exist in a TypeScript project using "lib": ["esnext"] without errors.

Test code to reproduce

Minimal repro at https://github.com/threehams/cypress-typescript-5-4

Cypress Version

13.9.0

Node version

20.10.0

Operating System

MacOS 14.4.1

Debug Logs

No response

Other

No response

@jennifer-shehane jennifer-shehane added type: typings Issue related to Cypress types (for TypeScript) stage: needs investigating Someone from Cypress needs to look at this labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this type: typings Issue related to Cypress types (for TypeScript)
Projects
None yet
Development

No branches or pull requests

2 participants