首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XXX不能同时扩展类型的YYY

XXX不能同时扩展类型的YYY
EN

Stack Overflow用户
提问于 2018-01-03 19:55:13
回答 1查看 985关注 0票数 1

我的tsconfig.json

代码语言:javascript
复制
{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "module": "es6",
    "target": "es5",
    "jsx": "react",
    "allowJs": true,
    "preserveConstEnums": true,
    "removeComments": true,
    "noImplicitAny": false,
    "moduleResolution": "node",
    "noUnusedParameters": true
  },
  "include": [
    "./src/**/*"
  ],
  "exclude": [
    "node_modules",
    "@typings",
    "typings/main",
    "typings/main.d.ts",
    "typings/index.d.ts"
  ],
  "paths": {
    "react": ["node_modules/@types/react"]
  }
}

我已经将karma-typescript添加到我的配置中。

代码语言:javascript
复制
settings.frameworks.push('karma-typescript');
settings.preprocessors['test-bundler.js'].unshift('karma-typescript');
settings.karmaTypescriptConfig = {
    tsconfig: './tsconfig.json',
};

使用webpack,开发服务器和编译工作很好。

这是一个模拟测试

代码语言:javascript
复制
describe('Root', () => {
    it('should pass', () => {
        console.log('done');
    });
});

当运行测试时,我得到

node_modules/@types/react/index.d.ts(2736,19):错误TS2320:接口'ElementClass‘不能同时扩展类型'Component’和'Component‘。命名属性‘支持’类型‘组件’和‘组件’是不一样的。

和那些相似。如果我删除了settings.preprocessors['test-bundler.js'].unshift('karma-typescript');,那么测试运行良好(但是当我开始导入源文件时,我无法预编译类型记录。

怎么一回事?我的正常构建和开发服务器在我所拥有的tsconfig.json中运行良好。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-03 20:56:46

发生了什么事

编译上下文中有两个react.d.ts

修复

再次删除node_modules和任何package-lock (或纱线锁)和npm install

如果它不能工作,找到无效模块(所有模块都应该将react.d.ts作为peerDependency而不是硬dependency)并报告其项目。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48084260

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档