handsome-cartoon-58565
02/04/2022, 12:16 AMhandsome-cartoon-58565
02/04/2022, 12:16 AMincluded/9.1.1
from https://github.com/cypress-io/cypress-docker-images/tree/master/included/9.1.1) and i receive error:
> error TS2688: Cannot find type definition file for 'cypress'.
I have installed TypeScript with npm install -g typescript
. The command i use to compile project is:
sh
tsc --project cypress/tsconfig.cypress.json
tsconfig.cypress.json
file:
json
{
"compilerOptions": {
"target": "es2020",
"lib": ["es5", "dom"],
"types": ["cypress"],
"allowJs": true,
},
"include": ["./integration/*.spec.ts"]
}
The mere Cypress has worked until i have been trying to add TypeScript.
From what i saw there are Cypress types inside /usr/local/lib/node_modules/cypress/types
folder and i even tried to put it inside typeRoots
prop, but then i receive errors of lacking definition files for npm
and yarn
.handsome-cartoon-58565
02/05/2022, 2:23 PMchai
and mocha
and that the Cypress types are really included inside /usr/local/lib/node_modules/cypress/types
folder (mind "/types"
instead of "/@types"
- don't know why they named it without "@"
though), so i don't have to install Cypress package separately, but just point to already existing types. I also had to add "ES2015"
lib types and modify "include"
to take all .ts files inside Cypress (nested) folders - except the /src
, which is provided by Docker volume not to mess with app's source code - instead of just including ./integration/*.spec.ts
files.
I now just install these:
sh
npm install -g typescript
npm install @types/mocha @types/chai
And i have such `tsconfig.cypress.json`:
json
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"lib": ["es5", "ES2015", "dom"],
"typeRoots": [
// official Cypress Docker container keeps types there
"/usr/local/lib/node_modules/cypress/types",
],
"types": ["cypress"],
"allowJs": true,
"resolveJsonModule": true
},
"include": ["./**/*.ts"],
"exclude": ["./fixtures/src"]
}