THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.
This tutorial explains about typescript compiler remove comments configuration You can also check how to generate tsconfig.json file and typescript tsconfig.json
Let’s write a typescript code Following code contains
// Hello World example
console.log("hello world");
/* Employee class contains
* Name
* Salary
* fields
**/
class Employee {
name?: string; // string or undefined
salary?: number; // number or undefined
// constructor
constructor(name: string, salary: number) {
this.name = name;
this.salary = salary;
}
}
When typescript transpiler to javascript, default comments are added to generate Javascript code.
Now, Let’s change compilerOptions
removeComments
to true
as given below
tsconfig.json
Set typescript compiler options removeComments
: true
{
"compilerOptions": {
"removeComments": true
}
}
Generated Javascript code as given below
It removes(Strips) comments from the original typescript code.
console.log("hello world");
class Employee {
name;
salary;
constructor(name, salary) {
this.name = name;
this.salary = salary;
}
}
use compileroptions
in tsconfig.json,
You can use the same setting in Angular and React using typescript projects.
🧮 Tags
Recent posts
Julia examples - Variable Type Nim example - Convert String to/from the Int How to get length of an array and sequence in Nim? Nim environment variables - read, set, delete, exists, and iterate examples? How to convert from single character to/from string in Nim?Related posts