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
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.
The only thing which worked for me was to specify the Target
on macOS and Windows. Please note the parameter -t
is standing for Target.
tsc -t es5 script.ts
You can run the command on your terminal.
try setting up a tsconfig.json file in your project:
{
"compilerOptions": {
"target": "es5"
}
"files": []
}
that will tell the typescript compiler to target a version specifically.
Finally worked out for me. Run the file then state the target flag
tsc script.ts --t es5
enter link description here
I was having the same problem. What I read from the docs is that the tsconfig.json file is ignored if you specify the files.
My tsconfig.json file
{
"compilerOptions": {
"target": "es5"
},
"include": [
"*.ts"
]
}
And I run it from command line
tsc && node *.js
Using Visual Stido 2017 ?
1- Solution Explorer>Right Click To Project
2- Add>New Item
3- (Search section >type this> typescript)
4- Select "TypeScript Json Configuration File"
thats it
at the end of this steps, tsconfig.json will be added to project with default set applied to ES5
you don't have to change anything. just recompile your project and error gonna out.