Getting a storm of "error TS5055" messages on every TypeScript Compile in VS Code

This problem occurred because the TypeScript compiler tries to transpile everything, including files that are already JavaScript, in which case it understandably complains that it will overwrite its input. I found no combination of "include" and "exclude" statements which could stop this behaviour.

The solution is to add a new field, "outDir", to the compilerOptions, so it looks like this

{
    "compilerOptions": {
        "module": "commonjs",
        "sourceMap": true,
        "watch": true,
        "allowJs": true,
        "outDir": "generated"
    }
}

This will cause tsc to copy ALL ts and js in your project to the specified folder. There will be no more of those pesky TS5055 errors.

If the import references in your project are all relative, this should be fine. Otherwise, for example, if your Node.js project is using a "public" folder at the top level, you might have to modify path references in your code accordingly.


The error is happening also when the d.ts are generated tsc take all files it found in the output directory and sub-directories by default.

Assuming your output is in the out directory, you have to exclude it in the tsconfig.json:

"compilerOptions": {
  // All the options you want...

  // Redirect output structure to the directory
  "outDir": "out"

  // Exclude here the directories you want ts do not compile...
  "exclude": [
    "out"
  ]
}

Changing allowJs in tsconfig.json from true to false will tell the typescript compiler to not transpile javascript files. That should fix the problem.

https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options