Accessors are only available when targeting ECMAScript 5 and higher 错误提示

来到这里,说明聪明又勤快的你,一定是在学习JavaScript的超大集群Typescript,幸幸苦苦写完代码:运行结果如下

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

大概意思是说需要 编译到版本ES5或以上
也就说说需要 需要指定编译到版本ES5或以上
那么这样指定就可以:

tsc 项目名称.ts -t es5
//
tsc class.ts -t es5

运行成功,继续愉快的书写set /get 方法

方法有效

来源:https://blog.csdn.net/qq_35617751/article/details/106355637

原文地址:https://www.cnblogs.com/xqschool/p/15786770.html