Follow-up on Decorators PR#590
Conversation
|
|
||
| // 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.
Nit, might read a little better as:
Using the export keyword between a decorator and a class is not allowed. Please use
export @dec classinstead"
There was a problem hiding this comment.
Yep, I think that's better too. Will make changes and push it
| 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.
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");
}| // 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.
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@outerand@innerto Foo but now it works correctly