TypeScript error: Cannot write file 'index.d.ts' because it would overwrite input file
<p>I have issue when run <code>tsc</code></p>

<pre><code>error TS5055: Cannot write file 'index.d.ts' because it would overwrite input file.
</code></pre>

<p>my <code>tsconfig.json</code>:</p>

<pre><code>{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "declaration": true,
    "newLine": "LF",
    "preserveConstEnums": true,
    "pretty": true,
    "experimentalDecorators": true
  },

  "exclude": [
    "node_modules",
    "typings"
  ]
}
</code></pre>

<p>This issue solved when:</p>

<ol>
<li>exclude <code>index.ts</code> in <code>tsconfig</code></li>
<li>run <code>tsc index.ts</code></li>
<li>Turn <code>declaration</code> off in <code>tsconfig</code></li>
<li>rename <code>index</code> to another name!</li>
</ol>

<p>I have same issue when change typescript main file in package.json<br>
for example: rename index.ts to foo.ts</p>

<p>change <code>package.json</code> to</p>

<pre><code>"typescript": {
  "main": "foo.ts"
}
</code></pre>

<p>tsc error:</p>

<pre><code>error TS5055: Cannot write file 'index.d.ts' because it would overwrite input file.
</code></pre>

<p>content of file no mater, any code content has same issue!</p>

<p>What can i do for fix it ?  </p>

<p>Source code: <a href="https://github.com/AliMD/Node.js-Telegram-Bot-API/tree/v0.0.2-0" rel="noreferrer">https://github.com/AliMD/Node.js-Telegram-Bot-API/tree/v0.0.2-0</a><br>
Thank you in advance.</p>