diff --git a/src/plugins/estree.js b/src/plugins/estree.js index 61e2a8e69c..179f16f963 100644 --- a/src/plugins/estree.js +++ b/src/plugins/estree.js @@ -221,16 +221,15 @@ export default (superClass: Class): Class => 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): Class => 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( diff --git a/src/types.js b/src/types.js index 950c2fdc6f..d4c1041ae8 100644 --- a/src/types.js +++ b/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; + kind?: "get" | "set" | "init"; + + variance?: ?FlowVariance; +}; diff --git a/test/fixtures/estree/object-method/basic/expected.json b/test/fixtures/estree/object-method/basic/expected.json index b432d8ad2d..de9baf8dff 100644 --- a/test/fixtures/estree/object-method/basic/expected.json +++ b/test/fixtures/estree/object-method/basic/expected.json @@ -158,7 +158,8 @@ }, "body": [] } - } + }, + "shorthand": false } ] }