Typescript Compile Error in type definition files

1.3k views Asked by At

I try to migrate an existing ES6 codebase to TypeScript 1.8. To smoothen the path I tried to apply following typescript compiler settings:

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

After compilation with tsc I have tons of compile errors in type definition files.

Example:

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='.

The type definitions are maintained by typings.

Hope someone can give me a hint what is wrong with my environment.

1

There are 1 answers

0
wjohnsto On BEST ANSWER

Your issue here is likely that sinon is being included twice. The reason is Typings creates a main.d.ts and browser.d.ts and duplicates some of the files. Read more on that here.

In short, what you want to do is change your tsconfig to resemble something like the following:

{
  "compilerOptions": {
    "target": "es6",
    "allowJs": true,
    "sourceMap": true,
    "jsx": "react",
    "outDir": "built"
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}