Add back shorthand field to Property (#580)

Also add some better types for estree
This commit is contained in:
Daniel Tschinder
2017-06-17 01:05:32 +02:00
committed by GitHub
parent 6b4fba4deb
commit e11794c735
3 changed files with 25 additions and 10 deletions

View File

@@ -221,16 +221,15 @@ export default (superClass: Class<Parser>): Class<Parser> => class extends super
isAsync: boolean,
isPattern: boolean
): ?N.ObjectMethod {
const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern);
const node: N.EstreeProperty = (super.parseObjectMethod(prop, isGenerator, isAsync, isPattern): any);
if (node) {
// $FlowIgnore
if (node.kind === "method") node.kind = "init";
// $FlowIgnore
node.type = "Property";
if (node.kind === "method") node.kind = "init";
node.shorthand = false;
}
return node;
return (node: any);
}
parseObjectProperty(
@@ -240,16 +239,16 @@ export default (superClass: Class<Parser>): Class<Parser> => class extends super
isPattern: boolean,
refShorthandDefaultPos: ?Pos
): ?N.ObjectProperty {
const node = super.parseObjectProperty(prop, startPos, startLoc, isPattern, refShorthandDefaultPos);
const node: N.EstreeProperty = (
super.parseObjectProperty(prop, startPos, startLoc, isPattern, refShorthandDefaultPos): any
);
if (node) {
// $FlowIgnore
node.kind = "init";
// $FlowIgnore
node.type = "Property";
}
return node;
return (node: any);
}
toAssignable(