Coming here shows that you are smart and diligent. You must be learning the super cluster typescript of JavaScript. Fortunately, you have worked hard to write the code: the running results are as follows
- error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
It generally means that you need to compile to version Es5 or above
that is, you need to specify that you need to compile to version Es5 or above
then you can specify this:
tsc project_name.ts -t es5 // example: tsc class.ts -t es5
Run successfully, continue to write the set/get method happily