Tìm kiếm trang web

Định nghĩa Typescript 2 cho mocha, jasmine gây trùng lặp định danh


Các bước để tái tạo:
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'.
...

Cấu trúc dự án của tôi:

node_modules
test.ts
tsconfig.json

Mã của tôi:

const a: number = 9;

Tệp tsconfig.json của tôi:

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

Câu trả lời #1

Tìm thấy nó. Sử dụng tùy chọn types trong tsconfig.json cùng với tsc phiên bản 2.x

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