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'>> {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
No TypeScript errors.
I can try to craft a more minimal reproduction as time permits.
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.
Current behavior:
In particular:
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:
cypress/cli/package.json
Line 66 in c912e09
Bumping
@types/jqueryfrom3.3.6to3.3.31(the latest version at this time) should resolve the issue (technically,3.3.23was 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/jquerywith the@types/jquery@3.3.31files, although I was not able to getdtslintto pass in the Cypress project itself due to conflicts somewhere:Looks like the same thing the automated PR (#3343) ran into back in March.
Additional information:
toElementis an old Internet Explorer property. The DOM types that ship with TypeScript no longer include it inlib.dom.d.ts. See this comment. I think it was removed in microsoft/TypeScript#32578. The version of@types/jquery(3.3.6) currently shipped with Cypress still use this property.The
@types/jquerypackage went through a restructure in 3.3.21. Prior to that, thetoElementkey in question was present on theJQuery.Event<...>interface inindex.d.ts. The new definition ofJQuery.Eventnow lives inmisc.d.tsalong with some new related types (TriggeredEvent,EventBase, etc.). None of these extend the same list of event types as the old version, and since none of them reference the now-absenttoElement, the problem is resolved.Since
@types/jquery3.3.22 does not work but 3.3.23 does, I narrowed down the commits between those version release dates to c6fe757c..bf2beee3 and I'm pretty sure it was fixed in [jquery] Improve declaration of Events API. DefinitelyTyped/DefinitelyTyped#30144.