Add back shorthand field to Property (#580)
Also add some better types for estree
This commit is contained in:
parent
6b4fba4deb
commit
e11794c735
@ -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(
|
||||
|
||||
15
src/types.js
15
src/types.js
@ -724,3 +724,18 @@ export type FlowFunctionTypeParam = Node;
|
||||
export type FlowTypeAnnotation = Node;
|
||||
export type FlowVariance = Node;
|
||||
export type FlowClassImplements = Node;
|
||||
|
||||
|
||||
// estree
|
||||
|
||||
export type EstreeProperty = NodeBase & {
|
||||
type: "Property";
|
||||
shorthand: boolean;
|
||||
key: Expression;
|
||||
computed: boolean;
|
||||
value: Expression;
|
||||
decorators: $ReadOnlyArray<Decorator>;
|
||||
kind?: "get" | "set" | "init";
|
||||
|
||||
variance?: ?FlowVariance;
|
||||
};
|
||||
|
||||
@ -158,7 +158,8 @@
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"shorthand": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user