I have a question regarding keeping ES6 syntax when transpiling to JavaScript. For example, if I write the following code:
class Person {
public name: string;
constructor(name: string) {
this.name = name;
}
}
let person = new Person('John Doe');
console.log(person.name);
When I transpile this with TypeScript (using "target": "es6" in tsconfig.json), it gives me the following output:
var Person = /** @class */ (function () {
function Person(name) {
this.name = name;
}
return Person;
}());
var person = new Person('John Doe');
console.log(person.name);
However, I would like TypeScript to provide me with the following output:
class Person {
constructor(name) {
this.name = name;
}
}
let person = new Person('John Doe');
console.log(person.name);
My current tsconfig.json configuration is as follows:
{
"compilerOptions": {
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true
}
}
Additionally, running the command:
tsc -t es6 app.ts
Produces the desired result.