I like to have my comments intact in the resulting javascript file, by default the compiler removes them. Is there a tsc parameter for that? (The use case is to keep /// reference path's = ... for chutzpah unit testing. )
Since 2015 you can create a tsconfig.json
in your project and add "removeComments": false
to its "compilerOptions"
property in order to keep your comments in the resulting javascript files.
tsconfig.json
file for your project from your terminal (if necessary)tsc -init
"removeComments": false
to your tsconfig.json
file inside the "compilerOptions"
propertyAt the end, you should expect your tsconfig.json
file content to be like this:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": false,
"removeComments": false
},
"exclude": [
"node_modules"
]
}
tsc myFile.ts
in order to keep your commentstsc --removeComments myFile.ts
in order to remove your commentsYou can learn more about tsconfig.json
compiler options on Typescriptlang.org tsconfig.json page.
Furthermore, according to the Typescript documentation, setting true
or false
to the "removeComments"
property will have no effect on copy-right header comments beginning with /*!
. Thus, they will always appear in your .js
files.
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