Reputation: 4545
I want to use getters and setters in Typescript. At the moment when I try this I get the following:
error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
How do I configure my compiler in IntelliJ 14? Are there any disadvantages to this? DOes this produce a different type of Javascript that will only work on certain browsers?
Thanks
Upvotes: 23
Views: 10187
Reputation: 55
I solved mine by compiling the file in command prompt using "tsc --target ES5 YourFile.ts"
Upvotes: -2
Reputation: 683
You can set the target version in your tsconfig.json:
"compilerOptions": {
"target": "es5"
}
Here is a list of all the compiler options.
Upvotes: 11
Reputation: 4545
To change the compiler options you need to go to the FileWatcher Dialogue.
Settings -> Tools -> File Watchers
Select TypeScript and hit the edit (pencil) button.
Add
--target es5
to the arguments field
Upvotes: 25
Reputation: 276057
Setup the watcher to use the compiler flag --target es5
.
Are there any disadvantages to this?
Properties (getter/setter) are not supported where es5 isn't supported (obsolete versions of browsers : see http://kangax.github.io/compat-table/es5/)
Upvotes: 3