My task is to write E2E typescript tests for an Angular 11 app. My test setup reflects their best practices. The problem I am facing is right now is that the app has some existing jQuery type dependencies (3.5.1) and Cypress (8.4.1) has its own global jQuery(3.3) type definitions which conflict with one another and I get the following error during runtime:
error TS6200: Definitions of the following identifiers conflict with those in another file: TypeOrArray, Node, htmlString...
The app compiles and runs but each routing request /request
results in the error Cannot get /request
. I have also observed that if I force it to recompile (using compile-on-save with dummy code) then it works perfectly after producing the same pre-runtime error.
Details about my setup:
/cypress/tsconfig.json
{
"extends": "../tsconfig.json",
"include": [
"./**/*.ts"
],
"compilerOptions": {
"target": "es5",
"lib": [
"es5",
"dom"
],
"types": [
"cypress", // this was supposed to ignore jquery types conflicts as per docs
"cypress-localstorage-commands",
]
}
}
tsconfig.json
{
"compileOnSave": true,
"include": [
"...", // other stuff
"**/*.d.ts",
"src/main.ts",
"src/polyfills.ts"
],
"exclude": [
"node_modules/cypress/*",
"cypress/support/index.d.ts"
],
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types",
"./@types"
],
"lib": [
"es2017",
"dom"
]
}
}
So my questions are:
- How do I fix the conflicting types issue?
- Why does it work the second time but not the first?
Things I tried thus far without success:
- Added skipLibcheck to each and to both.
- Configured tsconfig as per their docs to solve this issue
- Tried to
exclude
cypress within main tsconfig and jquery with cypress's tsconfig