How to configure "tsconfig.json" to create files in "project / src" and write the output to "project / lib"?

I tried using the following in the tsconfig.json file:

...

"declaration": true,
"rootDir": "./src/",
"outDir": "./lib/",

...

The first time I execute tsc, it works fine; but the second time that I execute tsc, I get an error message when I tsccomplain that it cannot write the output because it overwrites the input file.

It seems tscto be trying to include TypeScript declaration files that are written to my lib directory.

0
source share
1 answer

Just exclude the files in the folder lib:

{
  "compilerOptions": {
      "declaration": true,
      "rootDir": "./src/",
      "outDir": "./lib/",
   }
},
"exclude": [
    "node_modules",
    "lib"
    ]
}
+3
source

Source: https://habr.com/ru/post/1689939/


All Articles