我有一个带有 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)