add support for object literal decorators - fixes #1154
This commit is contained in:
parent
82384f4761
commit
85f2e79f95
@ -516,10 +516,15 @@ pp.parseObj = function(isPattern, refShorthandDefaultPos) {
|
||||
if (this.afterTrailingComma(tt.braceR)) break
|
||||
} else first = false
|
||||
|
||||
while (this.type === tt.at) {
|
||||
this.decorators.push(this.parseDecorator())
|
||||
}
|
||||
|
||||
let prop = this.startNode(), isGenerator = false, isAsync = false, start
|
||||
if (this.options.features["es7.objectRestSpread"] && this.type === tt.ellipsis) {
|
||||
prop = this.parseSpread()
|
||||
prop.type = "SpreadProperty"
|
||||
this.takeDecorators(prop)
|
||||
node.properties.push(prop)
|
||||
continue
|
||||
}
|
||||
@ -545,8 +550,12 @@ pp.parseObj = function(isPattern, refShorthandDefaultPos) {
|
||||
}
|
||||
this.parseObjPropValue(prop, start, isGenerator, isAsync, isPattern, refShorthandDefaultPos);
|
||||
this.checkPropClash(prop, propHash)
|
||||
this.takeDecorators(prop)
|
||||
node.properties.push(this.finishNode(prop, "Property"))
|
||||
}
|
||||
if (this.decorators.length) {
|
||||
this.raise(this.start, "You have trailing decorators with no property");
|
||||
}
|
||||
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
|
||||
}
|
||||
|
||||
|
||||
@ -475,7 +475,7 @@ pp.parseClass = function(node, isStatement) {
|
||||
if (this.eat(tt.semi)) continue
|
||||
if (this.type === tt.at) {
|
||||
this.decorators.push(this.parseDecorator())
|
||||
continue;
|
||||
continue
|
||||
}
|
||||
var method = this.startNode()
|
||||
this.takeDecorators(method)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user