文件不是在'rootDir'在柏tsconfig.json

0

的问题

我想要配置柏在我的项目。 我碰到的一个问题稿配置柏和我需要你的帮助! 这是我的项目看起来像:

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/"
    }
  ]
}

柏可以工作好不 "extends": "../tsconfig.json" 但我需要它,因为我想到出口文件从来源目录在我的柏ts文件。

可以请你给我的想法是什么是错的我的配置? 我希望不会改变主tsconfig.json文件,因为它运行我们的用户界面。 这是我的错误:

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.
1

最好的答案

1

你的问题是来自事实的全部 cypress 文件夹中不包含下 src. 当设置 cypress/tsconfig.json 文件中,你可以替代的 rootDir 酒店设在父 tsconfig.json 文件。

试图设置这一领域的柏目录。

...
"compilerOptions: {
    "rootDir": "./"
    ...
},
...

^上述可能的工作,因为 tsconfigcypress 目录。

2021-11-22 20:49:28

谢谢! 它帮助!
Anastasion

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................