@cypress/webpack-preprocessor: missing type dependencies and other type errors
See original GitHub issueCurrent behavior
Reduced test case: https://github.com/OliverJAsh/cypress-10-ts-errors
This is a brand new Cypress project using the latest version of all libraries.
Run yarn
and then tsc
.
Result:
$ tsc
node_modules/@cypress/webpack-preprocessor/dist/index.d.ts:1:23 - error TS2688: Cannot find type definition file for 'webpack-dev-server'.
1 /// <reference types="webpack-dev-server" />
~~~~~~~~~~~~~~~~~~
node_modules/@cypress/webpack-preprocessor/dist/index.d.ts:2:23 - error TS2688: Cannot find type definition file for 'webpack-dev-server-3'.
2 /// <reference types="webpack-dev-server-3" />
~~~~~~~~~~~~~~~~~~~~
node_modules/@cypress/webpack-preprocessor/dist/index.d.ts:4:26 - error TS7016: Could not find a declaration file for module 'bluebird'. '/Users/oliverash/Development/temp/cypress-10-ts-errors/node_modules/bluebird/js/release/bluebird.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/bluebird` if it exists or add a new declaration (.d.ts) file containing `declare module 'bluebird';`
4 import * as Promise from 'bluebird';
~~~~~~~~~~
Found 3 errors in the same file, starting at: node_modules/@cypress/webpack-preprocessor/dist/index.d.ts:1
I attempted to workaround these errors by installing some of the missing type dependencies: https://github.com/OliverJAsh/cypress-10-ts-errors/commit/0e602ffe9a4d89372e68c06e849d12fa32af23ff
However, now I have a different error:
$ tsc
cypress.config.ts:7:16 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type '"file:preprocessor"' is not assignable to parameter of type '"task"'.
7 on("file:preprocessor", webpackPreprocessor({}));
~~~~~~~~~~~~~~~~~~~
node_modules/cypress/types/cypress.d.ts:5521:5
5521 (action: 'task', tasks: Tasks): void
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The last overload is declared here.
node_modules/@cypress/webpack-preprocessor/dist/index.d.ts:2:23 - error TS2688: Cannot find type definition file for 'webpack-dev-server-3'.
2 /// <reference types="webpack-dev-server-3" />
~~~~~~~~~~~~~~~~~~~~
Found 2 errors in 2 files.
Errors Files
1 cypress.config.ts:7
1 node_modules/@cypress/webpack-preprocessor/dist/index.d.ts:2
Desired behavior
No type errors.
Test code to reproduce
See above.
Cypress Version
10.2.0
Other
Issue Analytics
- State:
- Created a year ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Webpack Compilation Error with Cypress 10 and Cucumber in ...
You're just missing the webpack process, from quick-start. Then configure your preferred bundler to process features files.
Read more >@cypress/webpack-preprocessor - npm
Start using @cypress/webpack-preprocessor in your project by running ... TypeScript icon, indicating that this package has built-in type ...
Read more >cypress-io/cypress - Gitter
This is usually caused by: - A missing file or dependency - A syntax error in the file or one of its dependencies...
Read more >Code Coverage - Cypress Documentation
As you write more and more end-to-end tests, you will find yourself wondering ... the application code and not 3rd party dependencies from...
Read more >unmet peer dependencies pnpm - You.com | The AI Search ...
Apparently if a nested module fails to install during npm install, subsequent npm install won't detect those missing nested dependencies. If that's the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also, if we don’t type check this file and we only rely on type checking inside our editors, the next time someone opens it in their editor they might be surprised to find a type error left by someone else. We type check all files in our CI build to ensure that all files remain free of type errors so there are no nasty surprises like this.
I copied pasted the
tsconfig.json
from here intocypress
then ranyarn tsc --project cyperss
. I just realized it was not compilingcypress.config.ts
, though - so actually, it’s not type checkingcypress.config.ts
. 👎, so disregard my initial comment.I wonder if
webpack-preprocessor
even needs thewebpack-dev-server
(andwebpack-dev-server-3
types) at all. It doesn’t list those dependencies anywhere, so I think this is probably a bug in how we generate our types. Either way, this seems like a bug to me.