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.

37 comments
Comment actions Permalink

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
Comment actions Permalink

```

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
Comment actions Permalink

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
Comment actions Permalink

When just loaded

After a while in the background (same code)

0
Comment actions Permalink

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

0
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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

0
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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

 

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

 

Thanks.

0
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

@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
Comment actions Permalink

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
Comment actions Permalink

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

0
Comment actions Permalink

The reason is using await keyword outside async-function.

Error message is confusing.

There is how to reproduce:

 

0
Comment actions Permalink

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

0
Comment actions Permalink

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

0
Comment actions Permalink

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

0
Comment actions Permalink

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

0
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

I figured out a workaround.  The error only occurs if parenthesis are around the async call.  You may want to add a bug for that.

Thanks,
Dave

0
Comment actions Permalink

Still I need a way to recreate it; please can you provide a code snippet?

0
Comment actions Permalink

Hello, I too am getting this error.

Webstorm 2018.1

Javascript is Flow (Flow and JSX in ECMAScript 6)

 

Code Snippet inside a .js file:

export const someFunc = (productId) => async dispatch => {
const heldListing = await dispatch(
API.secretEndpoint.someFunc({ product_id: productId}),
);
return heldListing;
};

the warning I get is "Local variable heldListing" is redundant for the declaration of  `heldListing`

 

0
Comment actions Permalink

Hmm.. and what is wrong with inlining heldListing?

0

Please sign in to leave a comment.