小编Wei*_*Wei的帖子

React 的 Cypress-cucumber-typescript 中无法包含 tsconfig.json

我有一个带有 React、Cypress-cucumber-preprocessor、Typescript(在 es5 中输出)的项目。当我使用官方示例其他示例
运行 cypress 时,它存在以下问题:

TypeScript error: cypress/integration/Google/google.ts(5,3): Error TS2304: Cannot find name 'cy'.

SyntaxError: 'import' and 'export' may appear only with 'sourceType: module'
Run Code Online (Sandbox Code Playgroud)

如果我tsconfig.json在 React 父文件夹中删除,它会修复Syntax Error但仍然有TypeScript error.
所以看起来好像tsconfig.json会出现这个问题,但是项目不应该没有tsconfig.json

这是我的tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "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, …
Run Code Online (Sandbox Code Playgroud)

cucumber typescript reactjs cypress

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

cucumber ×1

cypress ×1

reactjs ×1

typescript ×1