I hope I am not missing a point here. But how can I keep ES6 syntax when transpiling to JS. For instance, if I code:
class Person {
public name: string;
constructor(name: string) {
this.name = name;
}
}
let person = new Person('John Doe');
console.log(person.name);
TS gives me: ("target": "es6" in tsconfig.json)
var Person = /** @class */ (function () {
function Person(name) {
this.name = name;
}
return Person;
}());
var person = new Person('John Doe');
console.log(person.name);
But I want TS to give me:
class Person {
constructor(name) {
this.name = name;
}
}
let person = new Person('John Doe');
console.log(person.name);
My tsconfig.json is like this:
{
"compilerOptions": {
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true
}
}
P.S.: If I run the command:
tsc -t es6 app.ts
It works;
"target": "es6"should work afaik but you can also try"target": "es2015"which is the official name of ES6. In any case it seems like your target is not properly set or being picked up by the compiler.