Cypress' built-in lodash types are incompatible with TypeScript 5.2+.
threehams opened this issue · comments
David Edmondson commented
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