Async/await support

I'm getting red lines for es7 features.

When I just open the webstorm, it looks fine, but if I don't use webstorm and leave it in the background for 20 minutes or so, strangely, I get those red lines.

 

ps. The project is already set as ECMASCRIPT 6.

ps². The syntax is being used correctly. As I said when I just open, everything looks fine.

1
37 comments

So these are JSHint errors, not WebStorm own inspections.

JSHint doesn't yet provide async/await support. It's planned for JSHint 2.10 - see https://github.com/jshint/jshint/pull/3273

You can use ignore directive to calm down JSHint

/* jshint ignore:start */
(async () => {

const browser = await puppeteer.launch();

const page = await browser.newPage();

await page.goto('https://example.com');

await page.screenshot({path: 'example.png'});

await browser.close();

})();
/* jshint ignore:end */

But I'd strongly recommend using more up-to-date linters, like ESLint, that support ES6+ features and are far more flexible

2

Ok. Looks like it happens only in this specific project.

 

I'm going to try to remove its .idea folder let webstorm recreate it. What do you think?

1

1. webstorm version?

2. what file is it - .js, .jsx, .html, or?

3.  await can only be used inside a function marked with async... Is your function declared properly? Please provide the full code snippet

1

Works fine for me using the same syntax:

 

Is it the only project you have opened? Does the issue persist after caches invalidation?

 

As for syntax error shown in runtime, please check your Node.js version: async functions are not supported by Node versions older than version 7.6

1

what error messages can you see? Please hover over the highlighted strings and take a screenshot of error tooltips.

Also, please check if you have specific language versions set for subfolders (press the ellipsis button next to language version field to open the JavaScript Language Versions dialog)

1

Thank you Elena! It works now!

1

Please can you provide the full, self-containing code snippet that shows up the issue? Code might looks fine right on opening because indexing is not yet completed and error highlighting is off.

0

```

async function find (ctx) {
ctx.body = await myFetchedModel()

return ctx.body
}

```

In this case, i'm getting errors with the first and second lines.

 

The thing is, when it loads, the words asycn/await are colored as javascript key-words. And after a while in the background they loose their color and they look like errors.

 

0

Works fine for me. What WebStorm build do you use? Can you attach a screenshot that shows the errors (please hover over them so that the error messages are visible)?

0

When just loaded

After a while in the background (same code)

0

what errors do you see (error messages)? what files is this code declared in (.js, .html, or?) what build do you use?

0

Current Version: WebStorm 2016.2.3

Build number: WS-162.1812.21

 

They are all js files. The error message is:

`Expecting newline or semicolon`

 

Weird. What do you think?

0

the error indicates that language version is not EcmaScript 6... Is it the only project being open? Can you recreate the issue in a new project?

0

yes, worth trying. I'd also suggest invalidating caches (File | Invalidate caches, restart) prior to removing the folder... It may help

0

Both solutions didn't work.

 

That's a tricky one. haha.

 

Maybe it is fine to have only this project with this weird behaviour. 

0

strange indeed... Can you provide this project? Or, at least attach your idea.log (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files)?

0

https://drive.google.com/open?id=0ByqNMDQ53eZVTTdkMTdac09qSlU 

 

Sorry, I can't provide the project but idea.log files are in this url.

 

Thanks.

0

Nothing interesting in the logs:( I an see lots of 'StubProcessingHelperBase - unable to get stub builder for com.jetbrains.jsonSchema.JsonSchemaFileType' errors, but they don't look related to the issue (this is a problem indexing json schemes fixed in 2016.3), plus some traces from Markdown Navigator plugin that you have already disabled...

0

I got it.

If this one is mysterious like this, it is fine.

I will work one more week in this project, it is no big deal.

 

Thanks in advance.

0

I have a same promblem. 

 

: (

Javascript language version is ES6. React JSX is same result.

Also, I tried uninstall and erase all related files and new install.

(reference: http://www.uninstallmacapp.com/webstorm-10-0-2-removal.html )

But I have a same result with state of no plugins and default settings.

 

I'm using mac book pro 15' El capitan 10.11.6

ps.

I tried with webstorm new project with Empty Project and the problem is the same.

 

0

@Elena

I knew the reason. In my chain of arrow functions I misplaced async keyword. 

It's my fault but I think it is hard to recognize that with error message 'Expecting newline or semicolon' at the await keyword.

It would be better it provide more specific messages or can be inferred messages.

Anyway, thanks!

0

This problem was happening to me as well, and I discovered that commenting and uncommenting the constructor function made the red lines go away. Here's my code:

 

'use strict';

import ReactNative, {AsyncStorage} from 'react-native';

class GlobalModel {

constructor() {

}

async readLoginData(callback) {
try {
let loginToken = await AsyncStorage.getItem('login_token');
if (!loginToken) {
callback();
return;
}
callback(loginToken);
} catch (error) {
callback();
}
}

}

module.exports = new GlobalModel();

 

 

0

Looks like indexes are broken; please try invalidating caches (File | Invalidate caches, Restart)

0

The reason is using await keyword outside async-function.

Error message is confusing.

There is how to reproduce:

 

0

we plan to provide a special inspection with a quick fix - see https://youtrack.jetbrains.com/issue/WEB-24228

0

Hello, I have same bug. IntellijIDEA 2017.1 node.js plugin installed.

0

what javascript language version is selected in Preferences | Languages & Frameworks | JavaScript?

0

Thanks it was less than ecmascript 6. Now it's Ok.

0

Hi,

I am having this issue with Webstorm 2018.1.2.

The issue is on typescript files when the function return type is defined.  If I remove the ": Promise" piece below, there is no error.

0

Please provide the code snippet as text;

also, would you be so kind to start a new thread when reporting a new issue? this one is already long enough and includes different reports hardly related to each other

0

Please sign in to leave a comment.