TS1056

error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.

Broken Code ❌

User.ts
1
2
3
4
5
6
7
8
class User {
constructor(private firstName: string, private lastName: string) {
}

get fullName() {
return `${this.firstName} ${this.lastName}`;
}
}
tsconfig.json
1
2
3
4
5
{
"compilerOptions": {
"target": "es3"
}
}

Fixed Code ✔️

Set the “target” property in your “tsconfig.json” file to “es5” or higher:

tsconfig.json
1
2
3
4
5
{
"compilerOptions": {
"target": "es5"
}
}