[英]File is not under 'rootDir' in Cypress tsconfig.json
我正在嘗試在我的項目中配置賽普拉斯。 我遇到了賽普拉斯的 typescript 配置問題,我需要您的幫助:我的項目如下所示:
fronend/
- cypress/
-tsconfig.json
- src/
- tsconfig.json
- package.json
- cypreess.json
這是我來自賽普拉斯目錄的 tsconfig.json:
{
"extends": "../tsconfig.json",
"include": ["./**/*.ts"],
"exclude": [],
"compilerOptions": {
"types": ["cypress"],
"lib": ["es2015", "dom"],
"isolatedModules": false,
"composite": true
}
}
這是我前端目錄中的 tsconfig.json 文件:
{
"compilerOptions": {
"baseUrl": "src",
"rootDir": "src",
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.svg"],
"exclude": ["node_modules", "scripts"],
"references": [
{
"path": "./cypress/"
}
]
}
Cypress 可以在沒有"extends": "../tsconfig.json"
的情況下正常工作,但我需要它,因為我想從我的 cypress ts 文件中的 src 目錄導出文件。
你能告訴我我的配置有什么問題嗎? 我寧願不要更改主 tsconfig.json 文件,因為它運行我們的 UI。 這是我的錯誤:
File '/**/fronend/cypress/support/objects/client.ts' is not under 'rootDir' '/**/frontend/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Imported via '../../support/client' from file '/**/frontend/cypress/integration/EndToEndTests.spec.ts'
Matched by include pattern './**/*.ts' in '/**/frontend/cypress/tsconfig.json'ts(6059)
tsconfig.json(3, 15): File is matched by include pattern specified here.
您的問題來自cypress
文件夾的全部不包含在src
下的事實。 設置cypress/tsconfig.json
文件時,可以覆蓋父tsconfig.json
文件中設置的rootDir
屬性。
嘗試將該字段設置為 cypress 目錄。
...
"compilerOptions: {
"rootDir": "./"
...
},
...
^ 以上可能有效,因為tsconfig
在cypress
目錄中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.