mocha,jasmine的Typescript 2定义会导致重复的标识符

时间:2016-10-02 22:51:22

标签: typescript typescript-typings

重现步骤:
1)npm install @types/mocha @types/jasmine
2)tsc

node_modules/@types/jasmine/index.d.ts(9,18): error TS2300: Duplicate identifier 'describe'.
node_modules/@types/jasmine/index.d.ts(11,18): error TS2300: Duplicate identifier 'xdescribe'.
...
node_modules/@types/mocha/index.d.ts(33,13): error TS2300: Duplicate identifier 'describe'.
node_modules/@types/mocha/index.d.ts(34,13): error TS2300: Duplicate identifier 'xdescribe'.
...

我的项目结构:

node_modules
test.ts
tsconfig.json

我的代码:

const a: number = 9;

我的tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node"
  }
}

1 个答案:

答案 0 :(得分:5)

找到它。使用types中的tsconfig.json选项以及tsc版本2.x

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "types": []
  }
}