You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Acorn parses the semicolon in both export default (class{}); and export default (function(){}); as an EmptyStatement. Esprima doesn't. The same issue arises with named classes and functions, as in export default (class A{}); and export default (function a(){});. The ES6 spec seems to support Esprima's interpretation of these cases.
This appears to stem from a difference in how Acorn and Esprima treat anonymous classes and functions in default exports. Acorn treats them as expressions and Esprima treats them as declarations. See estree/estree#98 for a recent discussion of this.
So Acorn treats export default class{} as involving a class expression. Because a semicolon is not needed here, Acorn says that in default exports, any semicolon following a class expression is unnecessary (and therefore ends up getting parsed as an EmptyStatement). This works great in export default class{}, but overgeneralizes when dealing with export default (class{}); and export default (class A{});. This is what's happening with functions as well.
The text was updated successfully, but these errors were encountered:
Acorn parses the semicolon in both
export default (class{});
andexport default (function(){});
as an EmptyStatement. Esprima doesn't. The same issue arises with named classes and functions, as inexport default (class A{});
andexport default (function a(){});
. The ES6 spec seems to support Esprima's interpretation of these cases.This appears to stem from a difference in how Acorn and Esprima treat anonymous classes and functions in default exports. Acorn treats them as expressions and Esprima treats them as declarations. See estree/estree#98 for a recent discussion of this.
So Acorn treats
export default class{}
as involving a class expression. Because a semicolon is not needed here, Acorn says that in default exports, any semicolon following a class expression is unnecessary (and therefore ends up getting parsed as an EmptyStatement). This works great inexport default class{}
, but overgeneralizes when dealing withexport default (class{});
andexport default (class A{});
. This is what's happening with functions as well.The text was updated successfully, but these errors were encountered: