diff --git a/src/parser/statement.js b/src/parser/statement.js index bdf7729f48..7a88bc17d2 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -171,13 +171,12 @@ export default class StatementParser extends ExpressionParser { currentContextDecorators.push(decorator); } - if (allowExport && this.match(tt._export)) { - return; - } - - // special error for the common case of @dec export class - if (!allowExport && this.match(tt._export)) { - this.raise(this.state.start, "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead"); + if (this.match(tt._export)) { + if (allowExport) { + return; + } else { + this.raise(this.state.start, "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead"); + } } if (!this.match(tt._class)) { diff --git a/src/tokenizer/state.js b/src/tokenizer/state.js index 31512c12f6..ff2307f1d6 100644 --- a/src/tokenizer/state.js +++ b/src/tokenizer/state.js @@ -90,7 +90,8 @@ export default class State { labels: Array<{ kind: ?("loop" | "switch"), statementStart?: number }>; // Leading decorators. Last element of the stack represents the decorators in current context. - // Supports nesting of decorators, e.g. @foo(@bar class {}) class {} + // Supports nesting of decorators, e.g. @foo(@bar class inner {}) class outer {} + // where @foo belongs to the outer class and @bar to the inner decoratorStack: Array>; // Token store.