I have a quick question on the tsc
command being used with the arguments --build --clean
, which I understand is used for cleaning /wiping off the .js
files generated earlier by the Transpiler (tsc).
What is the speciality or significance of this command? If at all I need to remove all the .js
files, I can easily accomplish it through rm -rf *.js
or del *.js
in the directory.
Can someone educate me on the missing pieces if any?
The difference is that rm
will happily delete any files, even if they weren't generated by transpiling TypeScript.
NOTE!
tsc --build --clean
will only delete.js
files if there is a corresponding.ts
file that it would have been generated from. This means that, if you rename.ts
files, delete.ts
files, or create new.ts
files, and then runtsc --build --clean
, old.js
files that previously had corresponding.ts
files will no longer be deleted.If you really want to clean up before a build, especially when the set of
.ts
files has changed, you should instead delete your output folder a different way. For examplerm -rf dist/
in a unix shell, orrm -r -fo dist/
in Windows PowerShell. Or, assuming you probably use Node.js if you use TypeScript, use a cross-platform package likerimraf
to delete your output folder.