Niall Niall - 1 year ago 147
TypeScript Question

Can't use let in webstorm

I am studying typescript and I'm trying to create a simple let and it won't work because it says I need to use ECMA6 or higher. This is is the error message I'm getting in the typescript compiler:

Error:(11, 5) TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.

And this is the code:

class website{

let google = new website();

google.url = "";
google.facebookLikes = 23124;

I searched online and I found an answer that says to go to settings and langauges and frameworks and go to javascript and change it to EcmaScript6. I done this but I still get the same error.

If anyone can shed some light on this I would really appreciate it. Thanks.

Answer Source

You need to use the ES6 target just as the error suggests.
I don't know how you compile your typescript files, if it's using the builtin compiler or a file watcher, but in any case the compiler options have the target property which should be ES6 if you want to use let (and other es6 features).

If for example you are using tsconfig.json then it should look like this:

    "compilerOptions": {
        "target": "ES6",
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download