Skip to content

Cypress + TypeScript 3.6.2 errors due to outdated JQuery types #5065

@wKovacs64

Description

@wKovacs64

Current behavior:

node_modules/cypress/types/jquery/index.d.ts:8155:87 - error TS2344: Type '"button" | "view" | "screenX" | "screenY" | "altKey" | "bubbles" | "cancelable" | "changedTouc
hes" | "ctrlKey" | "detail" | "eventPhase" | "metaKey" | "pageX" | "pageY" | "shiftKey" | ... 13 more ... | "touches"' does not satisfy the constraint '"repeat" | "butto
n" | "code" | "view" | "location" | "screenX" | "screenY" | "y" | "altKey" | "bubbles" | "cancelable" | "changedTouches" | "ctrlKey" | "detail" | "eventPhase" | ... 55 m
ore ... | "DOM_KEY_LOCATION_STANDARD"'.
  Type '"toElement"' is not assignable to type '"repeat" | "button" | "code" | "view" | "location" | "screenX" | "screenY" | "y" | "altKey" | "bubbles" | "cancelable" |
"changedTouches" | "ctrlKey" | "detail" | "eventPhase" | ... 55 more ... | "DOM_KEY_LOCATION_STANDARD"'.

8155         TData = null> extends Partial<Pick<PointerEvent & KeyboardEvent & TouchEvent, 'altKey' | 'bubbles' | 'cancelable' |
                                                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8156         'changedTouches' | 'ctrlKey' | 'detail' | 'eventPhase' | 'metaKey' | 'pageX' | 'pageY' | 'shiftKey' | 'view' |
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8157         'char' | 'charCode' | 'key' | 'keyCode' | 'button' | 'buttons' | 'clientX' | 'clientY' | 'offsetX' | 'offsetY' |
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8158         'pointerId' | 'pointerType' | 'screenX' | 'screenY' | 'targetTouches' | 'toElement' | 'touches'>> {
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In particular:

Type '"toElement"' is not assignable to type ...

Desired behavior:

No TypeScript errors.

Steps to reproduce: (app code and test code)

I have a few "real" projects exhibiting this issue, but here's one:
wKovacs64/pwl#88

I can try to craft a more minimal reproduction as time permits.

Versions

Cypress: 3.4.1
TypeScript: 3.6.2

Possible fix:

"@types/jquery": "3.3.6",

Bumping @types/jquery from 3.3.6 to 3.3.31 (the latest version at this time) should resolve the issue (technically, 3.3.23 was the first version that worked, but may as well go for the latest?). It worked if I manually replaced the contents of <my_project>/node_modules/cypress/types/jquery with the @types/jquery@3.3.31 files, although I was not able to get dtslint to pass in the Cypress project itself due to conflicts somewhere:

Error: Errors in typescript@next for external dependencies:
../node_modules/@types/jquery/JQuery.d.ts(12941,5): error TS2375: Duplicate number index signature.
../node_modules/@types/jquery/legacy.d.ts(201,5): error TS2374: Duplicate string index signature.
../node_modules/@types/jquery/misc.d.ts(5,1): error TS6200: Definitions of the following identifiers conflict with those in another file: TypeOrArray, Node, htmlString, Selector, SuccessTextStatus, ErrorTextStatus, TextStatus, SuccessCallback, ErrorCallback, CompleteCallback, StatusCodeCallbacks, CSSHook, CallbackBase, Callback, Duration, Tweener, PropHook, EasingMethod, AnimationHook, Queue, QueueFunction, SpeedSettings, EventHandlerBase, EventHandler, TypeEventHandler, _TypeEventHandlers, SpecialEventHook, CoordinatesPartial, ValHook, _Falsy, jQuery, $, _Event, _UIEvent, _MouseEvent, _DragEvent, _KeyboardEvent, _TouchEvent, _FocusEvent
../node_modules/@types/jquery/misc.d.ts(24,9): error TS2374: Duplicate string index signature.
../node_modules/@types/jquery/misc.d.ts(1140,9): error TS2374: Duplicate string index signature.
../node_modules/@types/jquery/misc.d.ts(3788,9): error TS2374: Duplicate string index signature.
../node_modules/@types/jquery/misc.d.ts(3799,9): error TS2374: Duplicate string index signature.
../node_modules/@types/jquery/misc.d.ts(6405,9): error TS2374: Duplicate string index signature.
../node_modules/@types/jquery/misc.d.ts(6432,9): error TS2374: Duplicate string index signature.
../node_modules/@types/jquery/misc.d.ts(6550,9): error TS2374: Duplicate string index signature.
../node_modules/@types/jquery/misc.d.ts(6625,9): error TS2374: Duplicate string index signature.

Looks like the same thing the automated PR (#3343) ran into back in March.

Additional information:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions