Accessors are only available when targeting ECMAScript 5 and higher

前端 未结 14 1648
北荒
北荒 2020-12-23 13:07

I am trying to run this code but it is giving me following errors:

Animal.ts(10,13): error TS1056: Accessors are only available when targeting ECMAS

14条回答
  •  不思量自难忘°
    2020-12-23 13:41

    If you're dealing with single file you could do this

    tsc your-file.ts --target ES2016 --watch

    If you wants inside your tsconfig.json for entire project configuration

    { "compilerOptions": { "target": "ES2016" } "files": [] }

    You may want to use either ECMAScript numeric "es6", "es7", "es8" or year of release like "ES2015", "ES2016", "ES2017".

    ESNext targets latest supported ES proposed features.

提交回复
热议问题