From 54fa079bf4bfeedfa2538f4e72f3b2220f469b32 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sun, 29 Mar 2015 16:44:36 +1100 Subject: [PATCH] fixes #1114 - The visitor keys for `ObjectTypeAnnotation`s were incorrect so those nodes weren't being traversed so comments weren't attached for them. - The type parser wasn't eating the semicolons for the nodes so the `end` location of each of the type properties wasn't accurate which threw off the code generation newline algorithm. - Type properties hadn't been given the `UserWhitespacable` alias. --- plugins/flow.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/flow.js b/plugins/flow.js index 2021a7a4d9..4f57bf078d 100644 --- a/plugins/flow.js +++ b/plugins/flow.js @@ -215,6 +215,7 @@ pp.flow_parseObjectTypeIndexer = function (node, isStatic) { this.expect(tt.colon) node.value = this.flow_parseType() + this.flow_objectTypeSemicolon() return this.finishNode(node, "ObjectTypeIndexer") } @@ -251,6 +252,7 @@ pp.flow_parseObjectTypeMethod = function (start, isStatic, key) { node.static = isStatic node.key = key node.optional = false + this.flow_objectTypeSemicolon() return this.finishNode(node, "ObjectTypeProperty") } @@ -258,6 +260,7 @@ pp.flow_parseObjectTypeCallProperty = function (node, isStatic) { var valueNode = this.startNode() node.static = isStatic node.value = this.flow_parseObjectTypeMethodish(valueNode) + this.flow_objectTypeSemicolon() return this.finishNode(node, "ObjectTypeCallProperty") } @@ -307,13 +310,10 @@ pp.flow_parseObjectType = function (allowStatic) { node.value = this.flow_parseType() node.optional = optional node.static = isStatic + this.flow_objectTypeSemicolon() nodeStart.properties.push(this.finishNode(node, "ObjectTypeProperty")) } } - - if (!this.eat(tt.semi) && this.type !== tt.braceR) { - this.unexpected() - } } this.expect(tt.braceR) @@ -321,6 +321,12 @@ pp.flow_parseObjectType = function (allowStatic) { return this.finishNode(nodeStart, "ObjectTypeAnnotation") } +pp.flow_objectTypeSemicolon = function () { + if (!this.eat(tt.semi) && this.type !== tt.braceR) { + this.unexpected() + } +} + pp.flow_parseGenericType = function (start, id) { var node = this.startNodeAt(start)