Bug Report
Current behavior
require('@babel/parser').parse('function foo () {await bar();}', {sourceType: 'module', errorRecovery: true})
Uncaught [SyntaxError: Unexpected token, expected ";" (1:23)
] {
loc: Position { line: 1, column: 23 },
pos: 23
}
Should throw an error with better message.
Input Code
function foo () {await bar();}
Expected behavior
Mabe like this, when errorRecovery: false
require('@babel/parser').parse('function foo () {await bar();}', {sourceType: 'module'})
Uncaught [SyntaxError: 'await' is only allowed within async functions (1:17)
] {
loc: Position { line: 1, column: 17 },
pos: 17
}
The error message is much better.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
Through API, without config
Environment
- Babel version(s): v7.12.7
- Node/npm version: Node 14/npm 6
- OS: Windows 10
- Monorepo: no
- How you are using Babel: api
Possible Solution
I have no idea
Additional context
Issue on Prettier prettier/prettier#9799 and prettier/prettier#9084
Bug Report
Current behavior
Should throw an error with better message.
Input Code
Expected behavior
Mabe like this, when
errorRecovery: falseThe error message is much better.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
Through API, without config
Environment
Possible Solution
I have no idea
Additional context
Issue on Prettier prettier/prettier#9799 and prettier/prettier#9084