Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure babel parser throws exactly same recoverable errors when estree plugin is enabled #12375

Merged
merged 13 commits into from
Dec 3, 2020
Merged
Prev Previous commit
Next Next commit
fix: set bigInt to null when invalid bigInt value is parsed
e.g. 0.1n
  • Loading branch information
JLHwung committed Nov 19, 2020
commit ab0e2c0b3e0634af8506a178bdd3df5be41c40e5
9 changes: 7 additions & 2 deletions packages/babel-parser/src/plugins/estree.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>

estreeParseBigIntLiteral(value: any): N.Node {
// https://github.com/estree/estree/blob/master/es2020.md#bigintliteral
// $FlowIgnore
const bigInt = typeof BigInt !== "undefined" ? BigInt(value) : null;
let bigInt;
try {
// $FlowIgnore
bigInt = BigInt(value);
} catch {
bigInt = null;
}
const node = this.estreeParseLiteral(bigInt);
node.bigint = String(node.value || value);

Expand Down