"Types are not supported by current JavaScript version" after update to 2016.2

Recently updated to version 2016.2 from 2016.1 and ES6 types now show as errors ("Types are not supported by current JavaScript version"). In the Preferences -> Languages & Frameworks -> JavaScript settings page, "JavaScript language version" is set to "JSX Harmony" but "ECMAScript 6" also shows the same errors. Am I missing a setting somewhere?

Screenshot of the errors:



15 comments
Comment actions Permalink

Expected behavior - this is not a valid ECMAScript 6 syntax; it's not even listed in proposals at https://github.com/tc39/proposals. To use type annotations, please make sure to switch JavaScript language version to 'Flow' (you can hit Alt+Enter to switch to appropriate language version).

7
Comment actions Permalink

Well, changing to "Flow" solved it. Thanks!

(although Alt+Enter didn't show changing language versions as an option)

It's strange that 2016.1 allowed this syntax. For some reason I was thinking that this type syntax was part of Harmony. Our current build chain using babel and jsx harmony certainly allows it.

 

 

2
Comment actions Permalink

I am facing the same problem. changing to "Flow" didn't solve it for me.

Although the code is compiling correctly but these errors are just annoying. 

0
Comment actions Permalink

Changing version to Flow should help. Please try invalidating caches - does the problem persist? Also, what files do you work with - .js, .es6, .jsx, or?

0
Comment actions Permalink

Well the changes made in default settings didn't reflect in the files that were opened, but when you hover over the error, the popover suggests to change the version to ES6, clicking the popover fixed everything.

I was using .js files. Thanks for the support.

0
Comment actions Permalink

changes in default settings (File | Default Settings) only affect new projects; to change language version used for current project, use File | Settings (WebStorm | Preferences if you are on Mac OSX)

0
Comment actions Permalink

Yes Webstorm | Preferences worked for MAC OSX. I was changing in File | default Settings previously. Thank you.

0
Comment actions Permalink

Alt + Enter -> Change to Flow worked for me ;-)

4
Comment actions Permalink

Nothing worked for me. But then I used ultimate weapon - restart ide. And here you go)

0
Comment actions Permalink

Alt + Enter -> Change to Flow worked for me.

1
Comment actions Permalink

1. change to Flow or ECMAScript 6
2. remove folder .idea in project root => reopen project => worked for me.

1
Comment actions Permalink

Not sure what to set for Flow... nor what it's going to do or how it works exactly.

0
Comment actions Permalink

You don't need to specify a Flow package unless you'd like to use flow type checker; if you need it, make sure to install and set it up per instructions in https://www.jetbrains.com/help/webstorm/2018.3/using-the-flow-type-checker.html#ws_js_install_flow

0
Comment actions Permalink

I don't know if I need to use a flow type checker... I saw these options because a few replies here said that setting it to Flow would stop the 'const not supported' validation errors in .js files... I don't know what your doc link means by "recognize Flow structures"... we're not using Node, somebody just added `const` to our old legacy JavaScript code and I'm a new developer on the project.

0
Comment actions Permalink

>replies here said that setting it to Flow would stop the 'const not supported' validation errors in .js files...

If your code is a legacy plain JavaScript with `const`, you don't need using Flow at all; try setting JavaScript Language version to JavaScript 1.8.5 - it supports both `const` and `let`:

1

Please sign in to leave a comment.