Skip to content

Remove type dependencies from cli. #7194

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

Merged
merged 8 commits into from
May 14, 2020

Conversation

sainthkh
Copy link
Contributor

@sainthkh sainthkh commented May 1, 2020

User facing changelog

Removed type dependencies from cli and restored copying and importing types behavior.

Additional details

Why was this change necessary?

TypeScript fail because of the type conflicts.

What is affected by this change?

N/A

Any implementation details to explain?

Break index.d.ts into several d.ts files by topics. And used them internally to avoid internal type conflicts.

How has the user experience changed?

N/A

About testing.

It seems that I'm always saying this these days. But I have to say once again. This cannot be tested inside Cypress. Because we need to check node_modules folder doesn't have @types/mocha and @types/jest together after installation.

PR Tasks

  • [N/A] Have tests been added/updated?
  • Has the original issue been tagged with a release in ZenHub?
  • [N/A] Has a PR for user-facing changes been opened in cypress-documentation?
  • [N/A] Have API changes been updated in the type definitions?
  • [N/A] Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 1, 2020

Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.

  • Please write [WIP] in the title of your Pull Request if your PR is not ready for review - someone will review your PR as soon as the [WIP] is removed.
  • Please familiarize yourself with the PR Review Checklist and feel free to make updates on your PR based on these guidelines.

PR Review Checklist

If any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'.

User Experience

  • The feature/bugfix is self-documenting from within the product.
  • The change provides the end user with a way to fix their problem (no dead ends).

Functionality

  • The code works and performs its intended function with the correct logic.
  • Performance has been factored in (for example, the code cleans up after itself to not cause memory leaks).
  • The code guards against edge cases and invalid input and has tests to cover it.

Maintainability

  • The code is readable (too many nested 'if's are a bad sign).
  • Names used for variables, methods, etc, clearly describe their function.
  • The code is easy to understood and there are relevant comments explaining.
  • New algorithms are documented in the code with link(s) to external docs (flowcharts, w3c, chrome, firefox).
  • There are comments containing link(s) to the addressed issue (in tests and code).

Quality

  • The change does not reimplement code.
  • There's not a module from the ecosystem that should be used instead.
  • There is no redundant or duplicate code.
  • There are no irrelevant comments left in the code.
  • Tests are testing the code’s intended functionality in the best way possible.

Internal

  • The original issue has been tagged with a release in ZenHub.

@jrr
Copy link

jrr commented May 8, 2020

I attempted to test this with my project. Here's what I did (based on circle.yml and wild guesses):

  1. Clone [email protected]:sainthkh/cypress.git and switch to branch issue-6690
  2. yarn build --scope cypress
  3. cd cli/build; yarn pack
  4. (from my project) yarn remove cypress, yarn add ../path-to-fork/cypress/cli/build/cypress-v4.5.0.tgz
  5. (from my project) yarn

Is this the right way to use a fork that hasn't been published?

If so, it unfortunately looks like the #6690 symptom remains:

> yarn build
yarn run v1.22.0
(...)
$ react-scripts build
Creating an optimized production build...
Failed to compile.

/Users/jrr/repos/foobar/node_modules/@types/mocha/index.d.ts
TypeScript error in /Users/jrr/repos/foobar/node_modules/@types/mocha/index.d.ts(2680,13):
Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'Lifecycle', but here has type 'HookFunction'.  TS2403

    2678 |  * @see https://mochajs.org/api/global.html#beforeEach
    2679 |  */
  > 2680 | declare var beforeEach: Mocha.HookFunction;
         |             ^
    2681 |
    2682 | /**
    2683 |  * Execute before each test case.


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

> yarn why @types/mocha
yarn why v1.22.0
[1/4] 🤔  Why do we have the module "@types/mocha"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@types/[email protected]"
info Reasons this module exists
   - "cypress" depends on it
   - Hoisted from "cypress#@types#mocha"
info Disk size without dependencies: "108KB"
info Disk size with unique dependencies: "108KB"
info Disk size with transitive dependencies: "108KB"
info Number of shared dependencies: 0
✨  Done in 1.13s.
>

Here's the yarn.lock diff, in case that helps figure out what's going on with @types/mocha:

diff --git a/package.json b/package.json
index e2218fd..b709f4e 100644
--- a/package.json
+++ b/package.json
@@ -52,7 +52,7 @@
     "apollo": "^2.27.4",
     "apollo-link-schema": "^1.2.4",
     "cross-env": "^7.0.2",
-    "cypress": "4.2.0",
+    "cypress": "/Users/jrr/repos/cypress/cli/build/cypress-v4.5.0.tgz",
     "enzyme": "^3.11.0",
     "enzyme-adapter-react-16": "^1.15.2",
     "enzyme-to-json": "^3.4.4",
diff --git a/yarn.lock b/yarn.lock
index 0ac3b4b..09510e7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1503,6 +1503,32 @@
     date-fns "^1.27.2"
     figures "^1.7.0"
 
+"@cypress/[email protected]":
+  version "2.88.5"
+  resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.5.tgz#8d7ecd17b53a849cfd5ab06d5abe7d84976375d7"
+  integrity sha512-TzEC1XMi1hJkywWpRfD2clreTa/Z+lOrXDCxxBTBPEcY5azdPi56A6Xw+O4tWJnaJH3iIE7G5aDXZC6JgRZLcA==
+  dependencies:
+    aws-sign2 "~0.7.0"
+    aws4 "^1.8.0"
+    caseless "~0.12.0"
+    combined-stream "~1.0.6"
+    extend "~3.0.2"
+    forever-agent "~0.6.1"
+    form-data "~2.3.2"
+    har-validator "~5.1.3"
+    http-signature "~1.2.0"
+    is-typedarray "~1.0.0"
+    isstream "~0.1.2"
+    json-stringify-safe "~5.0.1"
+    mime-types "~2.1.19"
+    oauth-sign "~0.9.0"
+    performance-now "^2.1.0"
+    qs "~6.5.2"
+    safe-buffer "^5.1.2"
+    tough-cookie "~2.5.0"
+    tunnel-agent "^0.6.0"
+    uuid "^3.3.2"
+
 "@cypress/[email protected]":
   version "4.1.0"
   resolved "https://registry.yarnpkg.com/@cypress/webpack-preprocessor/-/webpack-preprocessor-4.1.0.tgz#8c4debc0b1abf045b62524d1996dd9aeaf7e86a8"
@@ -2941,6 +2967,34 @@
   dependencies:
     "@babel/types" "^7.3.0"
 
+"@types/[email protected]":
+  version "1.3.3"
+  resolved "https://registry.yarnpkg.com/@types/blob-util/-/blob-util-1.3.3.tgz#adba644ae34f88e1dd9a5864c66ad651caaf628a"
+  integrity sha512-4ahcL/QDnpjWA2Qs16ZMQif7HjGP2cw3AGjHabybjw7Vm1EKu+cfQN1D78BaZbS1WJNa1opSMF5HNMztx7lR0w==
+
+"@types/[email protected]":
+  version "3.5.29"
+  resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.29.tgz#7cd933c902c4fc83046517a1bef973886d00bdb6"
+  integrity sha512-kmVtnxTuUuhCET669irqQmPAez4KFnFVKvpleVRyfC3g+SHD1hIkFZcWLim9BVcwUBLO59o8VZE4yGCmTif8Yw==
+
+"@types/[email protected]":
+  version "1.1.40"
+  resolved "https://registry.yarnpkg.com/@types/chai-jquery/-/chai-jquery-1.1.40.tgz#445bedcbbb2ae4e3027f46fa2c1733c43481ffa1"
+  integrity sha512-mCNEZ3GKP7T7kftKeIs7QmfZZQM7hslGSpYzKbOlR2a2HCFf9ph4nlMRA9UnuOETeOQYJVhJQK7MwGqNZVyUtQ==
+  dependencies:
+    "@types/chai" "*"
+    "@types/jquery" "*"
+
+"@types/chai@*":
+  version "4.2.11"
+  resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.11.tgz#d3614d6c5f500142358e6ed24e1bf16657536c50"
+  integrity sha512-t7uW6eFafjO+qJ3BIV2gGUyZs27egcNRkUdalkud+Qa3+kg//f129iuOFivHDXQ+vnU3fDXuwgv0cqMCbcE8sw==
+
+"@types/[email protected]":
+  version "4.2.7"
+  resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.7.tgz#1c8c25cbf6e59ffa7d6b9652c78e547d9a41692d"
+  integrity sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==
+
 "@types/cheerio@*":
   version "0.22.16"
   resolved "https://registry.yarnpkg.com/@types/cheerio/-/cheerio-0.22.16.tgz#c748a97b8a6f781b04bbda4a552e11b35bcc77e4"
@@ -3031,6 +3085,20 @@
     jest-diff "^25.2.1"
     pretty-format "^25.2.1"
 
+"@types/jquery@*":
+  version "3.3.38"
+  resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-3.3.38.tgz#6385f1e1b30bd2bff55ae8ee75ea42a999cc3608"
+  integrity sha512-nkDvmx7x/6kDM5guu/YpXkGZ/Xj/IwGiLDdKM99YA5Vag7pjGyTJ8BNUh/6hxEn/sEu5DKtyRgnONJ7EmOoKrA==
+  dependencies:
+    "@types/sizzle" "*"
+
+"@types/[email protected]":
+  version "3.3.31"
+  resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-3.3.31.tgz#27c706e4bf488474e1cb54a71d8303f37c93451b"
+  integrity sha512-Lz4BAJihoFw5nRzKvg4nawXPzutkv7wmfQ5121avptaSIXlDNJCUuxZxX/G+9EVidZGuO0UBlk+YjKbwRKJigg==
+  dependencies:
+    "@types/sizzle" "*"
+
 "@types/json-schema@^7.0.3":
   version "7.0.4"
   resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339"
@@ -3043,16 +3111,21 @@
   dependencies:
     "@types/lodash" "*"
 
-"@types/lodash@*":
+"@types/lodash@*", "@types/[email protected]":
   version "4.14.149"
   resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.149.tgz#1342d63d948c6062838fbf961012f74d4e638440"
   integrity sha512-ijGqzZt/b7BfzcK9vTrS6MFljQRPn5BFWOx8oE0GYxribu6uV+aA9zZuXI1zc/etK9E8nrgdoF2+LgUw7+9tJQ==
 
-"@types/minimatch@*":
+"@types/minimatch@*", "@types/[email protected]":
   version "3.0.3"
   resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
   integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
 
+"@types/[email protected]":
+  version "5.2.7"
+  resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.2.7.tgz#315d570ccb56c53452ff8638738df60726d5b6ea"
+  integrity sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==
+
 "@types/[email protected]":
   version "2.5.4"
   resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.4.tgz#5245b6d8841fc3a6208b82291119bc11c4e0ce44"
@@ -3172,7 +3245,32 @@
     "@types/prop-types" "*"
     csstype "^2.2.0"
 
-"@types/[email protected]":
+"@types/[email protected]":
+  version "3.2.3"
+  resolved "https://registry.yarnpkg.com/@types/sinon-chai/-/sinon-chai-3.2.3.tgz#afe392303dda95cc8069685d1e537ff434fa506e"
+  integrity sha512-TOUFS6vqS0PVL1I8NGVSNcFaNJtFoyZPXZ5zur+qlhDfOmQECZZM4H4kKgca6O8L+QceX/ymODZASfUfn+y4yQ==
+  dependencies:
+    "@types/chai" "*"
+    "@types/sinon" "*"
+
+"@types/sinon@*":
+  version "9.0.0"
+  resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-9.0.0.tgz#5b70a360f55645dd64f205defd2a31b749a59799"
+  integrity sha512-v2TkYHkts4VXshMkcmot/H+ERZ2SevKa10saGaJPGCJ8vh3lKrC4u663zYEeRZxep+VbG6YRDtQ6gVqw9dYzPA==
+  dependencies:
+    "@types/sinonjs__fake-timers" "*"
+
+"@types/[email protected]":
+  version "7.5.1"
+  resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-7.5.1.tgz#d27b81af0d1cfe1f9b24eebe7a24f74ae40f5b7c"
+  integrity sha512-EZQUP3hSZQyTQRfiLqelC9NMWd1kqLcmQE0dMiklxBkgi84T+cHOhnKpgk4NnOWpGX863yE6+IaGnOXUNFqDnQ==
+
+"@types/sinonjs__fake-timers@*":
+  version "6.0.1"
+  resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.1.tgz#681df970358c82836b42f989188d133e218c458e"
+  integrity sha512-yYezQwGWty8ziyYLdZjwxyMb0CZR49h8JALHGrxjQHWlqGgc8kLdHEgWrgL0uZ29DMvEVBDnHU2Wg36zKSIUtA==
+
+"@types/sizzle@*", "@types/[email protected]":
   version "2.3.2"
   resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.2.tgz#a811b8c18e2babab7d542b3365887ae2e4d9de47"
   integrity sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==
@@ -5954,7 +6052,7 @@ [email protected]:
   resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
   integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
 
-[email protected], concat-stream@^1.5.0:
+concat-stream@^1.5.0, concat-stream@^1.6.2:
   version "1.6.2"
   resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34"
   integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==
@@ -6458,13 +6556,23 @@ cyclist@^1.0.1:
   resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
   integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=
 
-[email protected]:
-  version "4.2.0"
-  resolved "https://registry.yarnpkg.com/cypress/-/cypress-4.2.0.tgz#45673fb648b1a77b9a78d73e58b89ed05212d243"
-  integrity sha512-8LdreL91S/QiTCLYLNbIjLL8Ht4fJmu/4HGLxUI20Tc7JSfqEfCmXELrRfuPT0kjosJwJJZacdSji9XSRkPKUw==
+cypress@/Users/jrr/repos/cypress/cli/build/cypress-v4.5.0.tgz:
+  version "4.5.0"
+  resolved "/Users/jrr/repos/cypress/cli/build/cypress-v4.5.0.tgz#564868b4cbcf30a209e6d931b02a49ed15318204"
   dependencies:
     "@cypress/listr-verbose-renderer" "0.4.1"
+    "@cypress/request" "2.88.5"
     "@cypress/xvfb" "1.2.4"
+    "@types/blob-util" "1.3.3"
+    "@types/bluebird" "3.5.29"
+    "@types/chai" "4.2.7"
+    "@types/chai-jquery" "1.1.40"
+    "@types/jquery" "3.3.31"
+    "@types/lodash" "4.14.149"
+    "@types/minimatch" "3.0.3"
+    "@types/mocha" "5.2.7"
+    "@types/sinon" "7.5.1"
+    "@types/sinon-chai" "3.2.3"
     "@types/sizzle" "2.3.2"
     arch "2.1.1"
     bluebird "3.7.2"
@@ -6478,7 +6586,7 @@ [email protected]:
     eventemitter2 "4.1.2"
     execa "1.0.0"
     executable "4.1.1"
-    extract-zip "1.6.7"
+    extract-zip "1.7.0"
     fs-extra "8.1.0"
     getos "3.1.4"
     is-ci "2.0.0"
@@ -6487,12 +6595,11 @@ [email protected]:
     listr "0.14.3"
     lodash "4.17.15"
     log-symbols "3.0.0"
-    minimist "1.2.2"
+    minimist "1.2.5"
     moment "2.24.0"
     ospath "1.2.2"
     pretty-bytes "5.3.0"
     ramda "0.26.1"
-    request cypress-io/request#b5af0d1fa47eec97ba980cde90a13e69a2afcd16
     request-progress "3.0.0"
     supports-color "7.1.0"
     tmp "0.1.0"
@@ -7847,15 +7954,15 @@ extract-stack@^1.0.0:
   resolved "https://registry.yarnpkg.com/extract-stack/-/extract-stack-1.0.0.tgz#b97acaf9441eea2332529624b732fc5a1c8165fa"
   integrity sha1-uXrK+UQe6iMyUpYktzL8WhyBZfo=
 
-[email protected]:
-  version "1.6.7"
-  resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9"
-  integrity sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=
+[email protected]:
+  version "1.7.0"
+  resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.7.0.tgz#556cc3ae9df7f452c493a0cfb51cc30277940927"
+  integrity sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==
   dependencies:
-    concat-stream "1.6.2"
-    debug "2.6.9"
-    mkdirp "0.5.1"
-    yauzl "2.4.1"
+    concat-stream "^1.6.2"
+    debug "^2.6.9"
+    mkdirp "^0.5.4"
+    yauzl "^2.10.0"
 
 [email protected]:
   version "1.3.0"
@@ -7985,13 +8092,6 @@ fbjs@^1.0.0:
     setimmediate "^1.0.5"
     ua-parser-js "^0.7.18"
 
-fd-slicer@~1.0.1:
-  version "1.0.1"
-  resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65"
-  integrity sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=
-  dependencies:
-    pend "~1.2.0"
-
 fd-slicer@~1.1.0:
   version "1.1.0"
   resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e"
@@ -11568,21 +11668,16 @@ [email protected]:
   resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
   integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=
 
-[email protected]:
-  version "1.2.2"
-  resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.2.tgz#b00a00230a1108c48c169e69a291aafda3aacd63"
-  integrity sha512-rIqbOrKb8GJmx/5bc2M0QchhUouMXSpd1RTclXsB41JdL+VtnojfaJR+h7F9k18/4kHUsBFgk80Uk+q569vjPA==
+[email protected], minimist@^1.2.0, minimist@^1.2.5:
+  version "1.2.5"
+  resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
+  integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
 
 minimist@^1.1.1, minimist@^1.1.3:
   version "1.2.0"
   resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
   integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=
 
-minimist@^1.2.0, minimist@^1.2.5:
-  version "1.2.5"
-  resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
-  integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
-
 minipass-collect@^1.0.2:
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/minipass-collect/-/minipass-collect-1.0.2.tgz#22b813bf745dc6edba2576b940022ad6edc8c617"
@@ -11665,7 +11760,7 @@ [email protected], mkdirp@^0.5.0, mkdirp@~0.5.1:
   dependencies:
     minimist "0.0.8"
 
-[email protected], [email protected], mkdirp@^0.5.1:
+[email protected], [email protected], mkdirp@^0.5.1, mkdirp@^0.5.4:
   version "0.5.5"
   resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
   integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
@@ -14768,31 +14863,6 @@ [email protected], "request@>=2.76.0 <3.0.0", request@^2.87.0, request@^2.88.0:
     tunnel-agent "^0.6.0"
     uuid "^3.3.2"
 
-request@cypress-io/request#b5af0d1fa47eec97ba980cde90a13e69a2afcd16:
-  version "2.88.1"
-  resolved "https://codeload.github.com/cypress-io/request/tar.gz/b5af0d1fa47eec97ba980cde90a13e69a2afcd16"
-  dependencies:
-    aws-sign2 "~0.7.0"
-    aws4 "^1.8.0"
-    caseless "~0.12.0"
-    combined-stream "~1.0.6"
-    extend "~3.0.2"
-    forever-agent "~0.6.1"
-    form-data "~2.3.2"
-    har-validator "~5.1.3"
-    http-signature "~1.2.0"
-    is-typedarray "~1.0.0"
-    isstream "~0.1.2"
-    json-stringify-safe "~5.0.1"
-    mime-types "~2.1.19"
-    oauth-sign "~0.9.0"
-    performance-now "^2.1.0"
-    qs "~6.5.2"
-    safe-buffer "^5.1.2"
-    tough-cookie "~2.5.0"
-    tunnel-agent "^0.6.0"
-    uuid "^3.3.2"
-
 require-directory@^2.1.1:
   version "2.1.1"
   resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
@@ -17737,7 +17807,7 @@ yarn@^1.21.1:
   resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.0.tgz#acf82906e36bcccd1ccab1cfb73b87509667c881"
   integrity sha512-KMHP/Jq53jZKTY9iTUt3dIVl/be6UPs2INo96+BnZHLKxYNTfwMmlgHTaMWyGZoO74RI4AIFvnWhYrXq2USJkg==
 
-[email protected]:
+[email protected], yauzl@^2.10.0:
   version "2.10.0"
   resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"
   integrity sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=
@@ -17745,13 +17815,6 @@ [email protected]:
     buffer-crc32 "~0.2.3"
     fd-slicer "~1.1.0"
 
-[email protected]:
-  version "2.4.1"
-  resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005"
-  integrity sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=
-  dependencies:
-    fd-slicer "~1.0.1"
-
 [email protected]:
   version "3.1.1"
   resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"

@jennifer-shehane
Copy link
Member

@sainthkh there are some conflicts and a comment someone mentioning this doesn't fix all issues.

@sainthkh
Copy link
Contributor Author

@jrr

It works in my local setting. I tested in this order:

  1. Clone [email protected]:sainthkh/cypress.git and switch to branch issue-6690
  2. yarn build
  3. cd cli/build and yarn pack
  4. Create empty folder. And npm init -y
  5. Add a line to "dependencies" field. "cypress": "/path-to-fork/cypress/cli/build/cypress-v4.5.0.tgz",
  6. Add more dependencies: yarn add typescript @types/jest.
  7. Install them by yarn.
  8. Create hello.ts with console.log('hello world') inside.
  9. ./node_modules/.bin/tsc hello.ts --noEmit. => No type error.

It's the test for the failed example at #6690(comment).

I want you to check if there's @type things in cli/build/package.json. If so, something went wrong.

@bahmutov
Copy link
Contributor

Hmm, testing with https://github.com/arteforme/cypress-jest-types-issue from the issue

{
  "devDependencies": {
    "@types/enzyme": "^3.10.5",
    "@types/jest": "^25.1.4",
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.2",
    "enzyme-to-json": "^3.4.4",
    "jest": "^25.1.0",
    "jest-enzyme": "^7.1.2",
    "jest-extended": "^0.11.5",
    "jest-styled-components": "^7.0.0"
  }
}
  • Cypress v4.2.0 reports 9 errors
node_modules/@types/jest/index.d.ts:34:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

34 declare var beforeEach: jest.Lifecycle;
               ~~~~~~~~~~

  node_modules/cypress/types/mocha/index.d.ts:2680:13
    2680 declare var beforeEach: Mocha.HookFunction;
                     ~~~~~~~~~~
    'beforeEach' was also declared here.

node_modules/@types/jest/index.d.ts:36:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'afterEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

36 declare var afterEach: jest.Lifecycle;
               ~~~~~~~~~

  node_modules/cypress/types/mocha/index.d.ts:2698:13
    2698 declare var afterEach: Mocha.HookFunction;
                     ~~~~~~~~~
    'afterEach' was also declared here.

node_modules/@types/jest/index.d.ts:37:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'describe' must be of type 'SuiteFunction', but here has type 'Describe'.

37 declare var describe: jest.Describe;
               ~~~~~~~~

  node_modules/cypress/types/mocha/index.d.ts:2714:13
    2714 declare var describe: Mocha.SuiteFunction;
                     ~~~~~~~~
    'describe' was also declared here.

node_modules/@types/jest/index.d.ts:39:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xdescribe' must be of type 'PendingSuiteFunction', but here has type 'Describe'.

39 declare var xdescribe: jest.Describe;
               ~~~~~~~~~

  node_modules/cypress/types/mocha/index.d.ts:2735:13
    2735 declare var xdescribe: Mocha.PendingSuiteFunction;
                     ~~~~~~~~~
    'xdescribe' was also declared here.

node_modules/@types/jest/index.d.ts:40:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'it' must be of type 'TestFunction', but here has type 'It'.

40 declare var it: jest.It;
               ~~

  node_modules/cypress/types/mocha/index.d.ts:2749:13
    2749 declare var it: Mocha.TestFunction;
                     ~~
    'it' was also declared here.

node_modules/@types/jest/index.d.ts:42:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xit' must be of type 'PendingTestFunction', but here has type 'It'.

42 declare var xit: jest.It;
               ~~~

  node_modules/cypress/types/mocha/index.d.ts:2770:13
    2770 declare var xit: Mocha.PendingTestFunction;
                     ~~~
    'xit' was also declared here.

node_modules/@types/jest/index.d.ts:43:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'TestFunction', but here has type 'It'.

43 declare var test: jest.It;
               ~~~~

  node_modules/cypress/types/mocha/index.d.ts:2763:13
    2763 declare var test: Mocha.TestFunction;
                     ~~~~
    'test' was also declared here.

node_modules/@types/jest/index.d.ts:46:15 - error TS2451: Cannot redeclare block-scoped variable 'expect'.

46 declare const expect: jest.Expect;
                 ~~~~~~

  node_modules/cypress/types/index.d.ts:45:15
    45 declare const expect: Chai.ExpectStatic
                     ~~~~~~
    'expect' was also declared here.

node_modules/cypress/types/index.d.ts:45:15 - error TS2451: Cannot redeclare block-scoped variable 'expect'.

45 declare const expect: Chai.ExpectStatic
                 ~~~~~~

  node_modules/@types/jest/index.d.ts:46:15
    46 declare const expect: jest.Expect;
                     ~~~~~~
    'expect' was also declared here.


Found 9 errors.
  • Cypress v4.5.0 reports 9 errors
node_modules/@types/jest/index.d.ts:34:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

34 declare var beforeEach: jest.Lifecycle;
               ~~~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2680:13
    2680 declare var beforeEach: Mocha.HookFunction;
                     ~~~~~~~~~~
    'beforeEach' was also declared here.

node_modules/@types/jest/index.d.ts:36:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'afterEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

36 declare var afterEach: jest.Lifecycle;
               ~~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2698:13
    2698 declare var afterEach: Mocha.HookFunction;
                     ~~~~~~~~~
    'afterEach' was also declared here.

node_modules/@types/jest/index.d.ts:37:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'describe' must be of type 'SuiteFunction', but here has type 'Describe'.

37 declare var describe: jest.Describe;
               ~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2714:13
    2714 declare var describe: Mocha.SuiteFunction;
                     ~~~~~~~~
    'describe' was also declared here.

node_modules/@types/jest/index.d.ts:39:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xdescribe' must be of type 'PendingSuiteFunction', but here has type 'Describe'.

39 declare var xdescribe: jest.Describe;
               ~~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2735:13
    2735 declare var xdescribe: Mocha.PendingSuiteFunction;
                     ~~~~~~~~~
    'xdescribe' was also declared here.

node_modules/@types/jest/index.d.ts:40:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'it' must be of type 'TestFunction', but here has type 'It'.

40 declare var it: jest.It;
               ~~

  node_modules/@types/mocha/index.d.ts:2749:13
    2749 declare var it: Mocha.TestFunction;
                     ~~
    'it' was also declared here.

node_modules/@types/jest/index.d.ts:42:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xit' must be of type 'PendingTestFunction', but here has type 'It'.

42 declare var xit: jest.It;
               ~~~

  node_modules/@types/mocha/index.d.ts:2770:13
    2770 declare var xit: Mocha.PendingTestFunction;
                     ~~~
    'xit' was also declared here.

node_modules/@types/jest/index.d.ts:43:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'TestFunction', but here has type 'It'.

43 declare var test: jest.It;
               ~~~~

  node_modules/@types/mocha/index.d.ts:2763:13
    2763 declare var test: Mocha.TestFunction;
                     ~~~~
    'test' was also declared here.

node_modules/@types/jest/index.d.ts:46:15 - error TS2451: Cannot redeclare block-scoped variable 'expect'.

46 declare const expect: jest.Expect;
                 ~~~~~~

  node_modules/cypress/types/index.d.ts:41:15
    41 declare const expect: Chai.ExpectStatic
                     ~~~~~~
    'expect' was also declared here.

node_modules/cypress/types/index.d.ts:41:15 - error TS2451: Cannot redeclare block-scoped variable 'expect'.

41 declare const expect: Chai.ExpectStatic
                 ~~~~~~

  node_modules/@types/jest/index.d.ts:46:15
    46 declare const expect: jest.Expect;
                     ~~~~~~
    'expect' was also declared here.


Found 9 errors.
  • this PR sainthkh:issue-6690 reports 11 errors

Built CLI, packed it with

/cli
  npm run build
cd build
npm pack
~/git/cypress-jest-types-issue
npm i ~/git/cypress/cli/build/cypress-4.5.0.tgz
npm i

$ npx tsc
node_modules/@types/jest/index.d.ts:34:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

34 declare var beforeEach: jest.Lifecycle;
               ~~~~~~~~~~

  node_modules/cypress/types/mocha/index.d.ts:2680:13
    2680 declare var beforeEach: Mocha.HookFunction;
                     ~~~~~~~~~~
    'beforeEach' was also declared here.

node_modules/@types/jest/index.d.ts:36:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'afterEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

36 declare var afterEach: jest.Lifecycle;
               ~~~~~~~~~

  node_modules/cypress/types/mocha/index.d.ts:2698:13
    2698 declare var afterEach: Mocha.HookFunction;
                     ~~~~~~~~~
    'afterEach' was also declared here.

node_modules/@types/jest/index.d.ts:37:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'describe' must be of type 'SuiteFunction', but here has type 'Describe'.

37 declare var describe: jest.Describe;
               ~~~~~~~~

  node_modules/cypress/types/mocha/index.d.ts:2714:13
    2714 declare var describe: Mocha.SuiteFunction;
                     ~~~~~~~~
    'describe' was also declared here.

node_modules/@types/jest/index.d.ts:39:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xdescribe' must be of type 'PendingSuiteFunction', but here has type 'Describe'.

39 declare var xdescribe: jest.Describe;
               ~~~~~~~~~

  node_modules/cypress/types/mocha/index.d.ts:2735:13
    2735 declare var xdescribe: Mocha.PendingSuiteFunction;
                     ~~~~~~~~~
    'xdescribe' was also declared here.

node_modules/@types/jest/index.d.ts:40:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'it' must be of type 'TestFunction', but here has type 'It'.

40 declare var it: jest.It;
               ~~

  node_modules/cypress/types/mocha/index.d.ts:2749:13
    2749 declare var it: Mocha.TestFunction;
                     ~~
    'it' was also declared here.

node_modules/@types/jest/index.d.ts:42:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xit' must be of type 'PendingTestFunction', but here has type 'It'.

42 declare var xit: jest.It;
               ~~~

  node_modules/cypress/types/mocha/index.d.ts:2770:13
    2770 declare var xit: Mocha.PendingTestFunction;
                     ~~~
    'xit' was also declared here.

node_modules/@types/jest/index.d.ts:43:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'TestFunction', but here has type 'It'.

43 declare var test: jest.It;
               ~~~~

  node_modules/cypress/types/mocha/index.d.ts:2763:13
    2763 declare var test: Mocha.TestFunction;
                     ~~~~
    'test' was also declared here.

node_modules/@types/jest/index.d.ts:46:15 - error TS2451: Cannot redeclare block-scoped variable 'expect'.

46 declare const expect: jest.Expect;
                 ~~~~~~

  node_modules/cypress/types/cypress-expect.d.ts:2:15
    2 declare const expect: Chai.ExpectStatic
                    ~~~~~~
    'expect' was also declared here.

node_modules/cypress/types/cypress-expect.d.ts:2:15 - error TS2451: Cannot redeclare block-scoped variable 'expect'.

2 declare const expect: Chai.ExpectStatic
                ~~~~~~

  node_modules/@types/jest/index.d.ts:46:15
    46 declare const expect: jest.Expect;
                     ~~~~~~
    'expect' was also declared here.

node_modules/cypress/types/sinon/index.d.ts:17:29 - error TS2307: Cannot find module '@sinonjs/fake-timers'.

17 import * as FakeTimers from '@sinonjs/fake-timers';
                               ~~~~~~~~~~~~~~~~~~~~~~

node_modules/cypress/types/sinon/ts3.1/index.d.ts:1:29 - error TS2307: Cannot find module '@sinonjs/fake-timers'.

1 import * as FakeTimers from '@sinonjs/fake-timers';
                              ~~~~~~~~~~~~~~~~~~~~~~


Found 11 errors.

Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, does not solve the original problem reported for repo https://github.com/arteforme/cypress-jest-types-issue plus adds missing sinon/ fake timers types

node_modules/cypress/types/sinon/index.d.ts:17:29 - error TS2307: Cannot find module '@sinonjs/fake-timers'.

17 import * as FakeTimers from '@sinonjs/fake-timers';
                               ~~~~~~~~~~~~~~~~~~~~~~

node_modules/cypress/types/sinon/ts3.1/index.d.ts:1:29 - error TS2307: Cannot find module '@sinonjs/fake-timers'.

1 import * as FakeTimers from '@sinonjs/fake-timers';

@bahmutov bahmutov changed the base branch from develop to add-cy-and-jest-test-job May 14, 2020 20:29
@bahmutov bahmutov merged commit 4bf7a4f into cypress-io:add-cy-and-jest-test-job May 14, 2020
@sainthkh sainthkh mentioned this pull request Oct 12, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mocha type definitions conflict with @types/jest
4 participants