Async class method Unexpected token
See original GitHub issueTell us about your environment
- ESLint Version: 4.10.0
- Node Version: v.8.9.0
- npm Version: 5.5.1
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
class test {
constructor(){
this.help();
}
async help() {
const bla = await this.hello();
}
hello() {
return setTimeout(() => console.log('1'), 3000);
}
}
new test();
REPL
What did you expect to happen? No error.
What actually happened? Please include the actual, raw output from ESLint. Parsing error: Unexpected token help
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Async/Await in a Class : unexpected token `this` - Stack Overflow
To keep things simple, it happens because when you create a Promise, in its' constructor you pass an arrow function, which contains await...
Read more >SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >SyntaxError: Unexpected token function - Async Await Nodejs
JavaScript : SyntaxError: Unexpected token function - Async Await Nodejs [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] ...
Read more >Unexpected token. A constructor, method Error in TS
The "Unexpected token. A constructor, method, accessor, or property was expected" error occurs when we use the var or let keywords to declare...
Read more >Javascript async keyword not recognized for a class method
ERROR: Parsing error: Unexpected token cameraIni. The code will work normally in browsers, also is widelly used by this kind of application with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for the issue.
If you don’t have configuration file, you need to create it. ESLint parses source codes in ES5 mode by default. You can configure it via configuration file. For example:
See https://eslint.org/docs/user-guide/configuring for more information.
Okay thank you. I always get confused with versions these days.