2

我尝试将现有的 ES6 代码库迁移到 TypeScript 1.8。为了平滑路径,我尝试应用以下 typescript 编译器设置:

{
  "compilerOptions": {
    "target": "es6",
    "allowJs": true,
    "sourceMap": true,
    "jsx": "react",
    "outDir": "built"
  },
  "exclude": [
    "node_modules"
  ]
}

编译后,tsc我在类型定义文件中有大量编译错误。

例子:

typings/main/definitions/sinon/sinon.d.ts(436,1): error TS2300: Duplicate identifier 'export='.
typings/main/definitions/sinon/sinon.d.ts(440,1): error TS2300: Duplicate identifier 'export='.

类型定义由 维护typings

希望有人能给我提示我的环境有什么问题。

4

1 回答 1

2

您在这里的问题可能是 sinon 被包含两次。原因是 Typings 创建了一个main.d.ts并且browser.d.ts复制了一些文件。在此处阅读更多信息。

简而言之,您要做的是将您的 tsconfig 更改为类似于以下内容:

{
  "compilerOptions": {
    "target": "es6",
    "allowJs": true,
    "sourceMap": true,
    "jsx": "react",
    "outDir": "built"
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}
于 2016-02-16T15:52:09.760 回答