Reactjs Can';t在Cypress cucumber typescript中没有用于React的tsconfig.json
我有一个带有React、Typescript(在es5中输出)的项目。Reactjs Can';t在Cypress cucumber typescript中没有用于React的tsconfig.json,reactjs,typescript,cucumber,cypress,Reactjs,Typescript,Cucumber,Cypress,我有一个带有React、Typescript(在es5中输出)的项目。 当我使用or运行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' 如果我删除React父
当我使用or运行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'
如果我删除React父文件夹中的tsconfig.json
,它修复了语法错误
,但仍然存在TypeScript错误
因此,似乎是
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,
"noEmit": true,
"jsx": "react"
},
"include": [
"src"
]
}
错误TS2304:找不到名称“cy” 您应该在文件顶部添加:
//
你能发布你的tsconfig
吗?@Brendan是的,我发布了。我怀疑这是因为你在tsconfig
中只包含src
,所以你的测试不包括在内。尝试更改为:“include”:[“src”,“cypress”]
@Brendan它仍然存在与错误TS2304相同的问题:找不到名称“cy”。