How to setup 'tsconfig.json' to build files in 'project/src' and write output to 'project/lib'?

梦想与她 提交于 2019-12-11 13:46:28

问题


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

...

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

...

The first time I execute tsc it seems to work fine; but the second time I execute tsc I get an error where tsc complains that it cannot write output because it would overwrite an input file.

It seems that tsc is trying to include the TypeScript declaration files that are written out to my 'lib' directory.


回答1:


Just exclude the files in the lib folder:

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


来源:https://stackoverflow.com/questions/35800517/how-to-setup-tsconfig-json-to-build-files-in-project-src-and-write-output-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!