You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已安装的Cypress覆盖zx全局$变量,未导入仍触发类型错误

全局变量$类型冲突:zx 与 Cypress

我同时安装了zx和Cypress工具,zx将全局变量$定义为命令运行器,而Cypress将其定义为JQuery实例。我从未在任何位置导入Cypress的类型文件,但在使用zx的$时,会触发类似Property 'stdout' does not exist on type 'JQuery<HTMLSelectElement>'的类型错误,卸载Cypress后该错误消失。

我尝试将Cypress相关路径添加到tsconfig的exclude配置中,但并未解决问题。以下是我的TSConfig相关配置内容:

tsconfig-base.json

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "allowJs": true,
    "noEmit": true,
    "noEmitHelpers": true,
    "strict": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "baseUrl": "./",
    "noImplicitAny": true,
    "noImplicitOverride": true,
    "strictNullChecks": true,
    "useUnknownInCatchVariables": true,
    "resolveJsonModule": false,
    "lib": ["es2021"],
    "types": [
      "webpack-env"
    ],
    "experimentalDecorators": true,
    "noErrorTruncation": true
  },
  "exclude": [
    "./node_modules",
    "./node_modules/cypress/types/jquery"
  ]
}

scripts/tsconfig.json

{
  "extends": "../tsconfig-base.json",
  "compilerOptions": {
    "checkJs": true,
    "noImplicitAny": false,
    "rootDir": ".",
    "types": [
      "webpack-env",
      "zx"
    ]
  },
  "include": [
    "."
  ]
}

内容的提问来源于stack exchange,提问作者Leo Jiang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 05:01:33