Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Typescript:如何管理具有冲突类型声明的依赖关系?_Javascript_Typescript_Types_Jestjs_Testcafe - Fatal编程技术网

Javascript Typescript:如何管理具有冲突类型声明的依赖关系?

Javascript Typescript:如何管理具有冲突类型声明的依赖关系?,javascript,typescript,types,jestjs,testcafe,Javascript,Typescript,Types,Jestjs,Testcafe,我有一个错误:后续变量声明必须具有相同的类型 这是因为我的两个依赖项,这两个都是我需要的;声明相同的类型 Jest:/node\u modules/@types/Jest/index.d.ts=>声明var测试:Jest. testcafenode\u模块/testcafe//ts defs/index.d.ts=>声明var测试:TestFn 我的项目是一个react/redux项目,使用webpack、babel和Typescript 当我通过使用webpack dev server的npm

我有一个错误:
后续变量声明必须具有相同的类型

这是因为我的两个依赖项,这两个都是我需要的;声明相同的类型

Jest
/node\u modules/@types/Jest/index.d.ts
=>
声明var测试:Jest.

testcafe
node\u模块/testcafe//ts defs/index.d.ts
=>
声明var测试:TestFn

我的项目是一个react/redux项目,使用webpack、babel和Typescript

当我通过使用
webpack dev server
npm start
运行dev服务器时,会发生此错误。当我运行
jest
时,它也会产生问题,因为它使用了testcafe版本的声明的
Test
类型

如何解决这一问题?

根据此处的讨论:

您可以排除TestCafe在本地
tsconfig.json
文件中查找的端到端测试文件

这是一个黑客,但它为我工作

示例
tsconfig.json
文件,假设所有端到端测试模块都在
test/e2e
下:

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "sourceMap": true,
    "strict": true,
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true
  },
  "exclude": [
    "test/e2e"
  ]
}

两个库声称拥有相同的全局变量-在运行时实际情况会是这样?@RyanCavanaugh当我通过使用
webpack dev server的
npm start
运行我的dev服务器时,会发生这种情况。当我运行
jest
时,它也会产生问题,因为它使用了
testcafe
的测试类型版本。@RyanCavanaugh当我运行
npm start
时,它也会运行
webpack dev server
,因为jest和testcafe都在执行中。我认为现在发生的是typescript正在检查所有与项目相关联的index.d.ts文件,不管它们是否正在使用