-
-
Notifications
You must be signed in to change notification settings - Fork 258
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/parser/statement.js
Outdated
@@ -173,6 +173,11 @@ export default class StatementParser extends ExpressionParser { | |||
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 decorators and class is disallowed. Please use `export @dec class` instead"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, might read a little better as:
Using the export keyword between a decorator and a class is not allowed. Please use
export @dec class
instead"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I think that's better too. Will make changes and push it
src/parser/statement.js
Outdated
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"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd combine this with the above clause, personally -
if (this.match(tt._export)) {
if (allowExport) {
return;
}
this.raise(this.state.start, "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead");
}
src/tokenizer/state.js
Outdated
// Leading decorators. | ||
decorators: Array<N.Decorator>; | ||
// Leading decorators. Last element of the stack represents the decorators in current context. | ||
// Supports nesting of decorators, e.g. @foo(@bar class {}) class {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd clarify here that foo
applies only to the second class and bar
only to the first.
Haven't checked over all the output carefully, especially the source locations, but otherwise LGTM. |
@hzoo do note that this isn't as big a change as the previous PR was so it wouldn't need as many reviews (in fact we could do with 2-3 reviews just like for any standard bugfix PR). |
Yeah I don't think we need all the reviews just pinging people anyway 👍 |
@dec export class {}
is encountered, suggesting the user to useexport @dec class {}
instead (only happens in the new decorators2 plugin). As requested by @hzoo@outer
and@inner
to Foo but now it works correctly