Accessors are only available when targeting ECMAScript 5 and higher

前端 未结 14 1631
北荒
北荒 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 14:04

    Had the same issue, got it worked with this... for a single file!

    tsc -target "es5" filename && node filename

    • "es5" with quotes
    • need not mention file extensions

    • tsc -target "es5" filename - transpiles the typescript to "es5" JavaScript

    • node filename - runs the transpiled javascript file

    0 讨论(0)
  • 2020-12-23 14:08

    I know that is an old conversation, but i think that solution bellow could be a very helpful command for all developers here.

    You can easily solve using this command in your Terminal, Command Prompt, Git Bash and etc:

    tsc --target ES2016 Animal.ts --watch

    or

    tsc --target es5 Animal.ts --watch

    --watch is optional and means that you doesn't need to compile your code in each modification.

    0 讨论(0)
提交回复
热议问题