Refactor parsing object members (#9607)
* Refactor parsing object members * Ensure decorators on rest don’t swallow decorators silently * Use hasPrecedingLineBreak * Add test for async with linebreak * Update flow whitelist
This commit is contained in:
@@ -126,16 +126,24 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
checkPropClash(
|
||||
prop: N.ObjectMember,
|
||||
prop: N.ObjectMember | N.SpreadElement,
|
||||
propHash: { [key: string]: boolean },
|
||||
): void {
|
||||
if (prop.computed || !isSimpleProperty(prop)) return;
|
||||
if (
|
||||
prop.type === "SpreadElement" ||
|
||||
prop.computed ||
|
||||
prop.method ||
|
||||
// $FlowIgnore
|
||||
prop.shorthand
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const key = prop.key;
|
||||
// It is either an Identifier or a String/NumericLiteral
|
||||
const name = key.type === "Identifier" ? key.name : String(key.value);
|
||||
|
||||
if (name === "__proto__") {
|
||||
if (name === "__proto__" && prop.kind === "init") {
|
||||
if (propHash.proto) {
|
||||
this.raise(key.start, "Redefinition of __proto__ property");
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const restNode: N.TsRestType = this.startNode();
|
||||
this.next(); // skips ellipsis
|
||||
restNode.typeAnnotation = this.tsParseType();
|
||||
this.checkCommaAfterRest(tt.bracketR, "type");
|
||||
this.checkCommaAfterRest();
|
||||
return this.finishNode(restNode, "TSRestType");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user