I have a project created in Visual Studio 2017 using the TypeScript Basic Node.js Express 4 Application template.
I have a file /public/scripts/script.js meant for download to the client. When I tried to build the application I get:
TS5055 Cannot write file 'd:/documents/visual studio 2017/Projects/ExpressApp/ExpressApp/public/scripts/script.js' because it would overwrite input file.
What does this error mean? Why would it want to write to this file? The error is there even if I exclude this file from the Project. How do I rectify this?
I renamed the folder from scripts to js and the problem is still the same. The only way to build successfully was to delete the file. Where then do I place files meant for the client?
Is there documentation available on the Visual Studio project folder structure for a TypeScript/Node project?
From the tip by @unional I found my answer, ie, have an explicit exclude option in tsconfig.json.
According to typescriptlang.org:
the compiler defaults to including all TypeScript (.ts, .d.ts and .tsx) files in the containing directory and subdirectories except those excluded using the "exclude" property. JS files (.js and .jsx) are also included if allowJs is set to true
If exclude is not specified, then only node_modules and a couple of others are excluded. The following worked for me:
"exclude": [ "node_modules", "public"]
Note that exclude is not a property of compilerOptions but is at the same level as compilerOptions in tsconfig.json.
Another option that works in VSCode is to use '"outFile":"out.js"' under '"CompilerOptions"' section to have a separate output file. This way you can still check those files, but not get the writing error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With