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 + TypeScript 3.6.2 errors due to outdated JQuery types #5065

Closed
wKovacs64 opened this issue Aug 29, 2019 · 10 comments · Fixed by #5230
Closed

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

wKovacs64 opened this issue Aug 29, 2019 · 10 comments · Fixed by #5230
Assignees

Comments

@wKovacs64
Copy link

wKovacs64 commented Aug 29, 2019

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:

@brandonb927
Copy link

I found that adding "skipLibCheck": true to my compilerOptions in tsconfig.json alleviated this issue after noticing that the officially-supported config recommends that when using Browserify as the preprocessor.

@bahmutov
Copy link
Contributor

bahmutov commented Sep 4, 2019

so I see this is jQuery + testing library issue when finding and triggering elements, which clashes with older jQuery TS definition in Cypress.

  1. before upgrading types/jquery from "@types/jquery": "3.3.6" I would like to have a failing test in cli/types/tests/cypress-tests.ts that recreates the problem when running npm run types in CLI folder
  2. upgrading just the types could work, even if the actual jQuery in packages/driver is still on v2 and the work to upgrade it is ongoing bump jquery to 3.1.1 #1229

@wKovacs64
Copy link
Author

wKovacs64 commented Sep 5, 2019

I don't think testing-library has anything to do with it - I have another project that does not use T-L and it still produces this error when attempting to use TypeScript 3.6.2.

I've updated the Additional Information section after learning more about the situation.

I'm not sure how to test it since the types tests are run with multiple versions of TS. Using the problematic event property (toElement) should succeed prior to TS 3.6.2, and fail as of TS 3.6.2, so... unless there's some way to specify TS versions for individual dtslint assertions that I don't know about... ¯\_(ツ)_/¯

@maryhipp
Copy link

maryhipp commented Sep 6, 2019

We are seeing this exact same thing when trying to build our package
cypress@3.4.1
typescript@3.6.2

../node_modules/cypress/types/jquery/index.d.ts:8155:87 - error TS2344: Type '"button" | "view" | "altKey" | "bubbles" | "cancelable" | "changedTouches" | "ctrlKey" | "detail" | "eventPhase" | "metaKey" | "pageX" | "pageY" | "shiftKey" | "char" | "charCode" | ... 13 more ... | "touches"' does not satisfy the constraint '"repeat" | "button" | "code" | "view" | "y" | "altKey" | "bubbles" | "cancelable" | "changedTouches" | "ctrlKey" | "detail" | "eventPhase" | "metaKey" | "pageX" | "pageY" | "shiftKey" | ... 54 more ... | "DOM_KEY_LOCATION_STANDARD"'.
  Type '"toElement"' is not assignable to type '"repeat" | "button" | "code" | "view" | "y" | "altKey" | "bubbles" | "cancelable" | "changedTouches" | "ctrlKey" | "detail" | "eventPhase" | "metaKey" | "pageX" | "pageY" | "shiftKey" | ... 54 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'>> {
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@wandri
Copy link

wandri commented Sep 9, 2019

Same problem for us. Do you know which packages to downgrade to avoid this error ?

@wKovacs64
Copy link
Author

@wandri TypeScript itself - 3.5.3 is fine, 3.6.2 is not.

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Sep 9, 2019
@JustFly1984
Copy link

Having same issue, ts 3.6.2

@bahmutov bahmutov self-assigned this Sep 27, 2019
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope labels Sep 29, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Sep 29, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 29, 2019

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

@JustFly1984
Copy link

JustFly1984 commented Oct 22, 2019

is there any movement on this release? this bug is ruining our pre-commit script

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2019

Released in 3.5.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants