在学习typescript属性的封装时,用到set方法和get方法时的错误提示:

​​Accessors are only available when targeting ECMAScript 5 and higher.

大概就是说:访问器仅在针对ECMAScript 5及更高版本时可用。
可以通过命令指定:

tsc 项目名称 -t es5
tsc demo.ts -t es5

更多推荐

报错:Accessors are only available when targeting ECMAScript 5 and higher.