Parse flow nested array type annotations like number[][] (#219)

* Parse flow nested array type annotations like number[][]

Fixes #217.

* Do not parse a newline separated array statement into a flow type annotation

* Get rid of lineBreak dependency in flow.js in favor of higher level method
This commit is contained in:
Bernhard Häussner
2016-11-13 10:22:16 +01:00
committed by Daniel Tschinder
parent 6cb023590a
commit 01ed943deb
7 changed files with 457 additions and 6 deletions

View File

@@ -690,15 +690,16 @@ pp.flowParsePrimaryType = function () {
};
pp.flowParsePostfixType = function () {
let node = this.startNode();
let type = node.elementType = this.flowParsePrimaryType();
if (this.match(tt.bracketL)) {
const startPos = this.state.start, startLoc = this.state.startLoc;
let type = this.flowParsePrimaryType();
while (!this.canInsertSemicolon() && this.match(tt.bracketL)) {
const node = this.startNodeAt(startPos, startLoc);
node.elementType = type;
this.expect(tt.bracketL);
this.expect(tt.bracketR);
return this.finishNode(node, "ArrayTypeAnnotation");
} else {
return type;
type = this.finishNode(node, "ArrayTypeAnnotation");
}
return type;
};
pp.flowParsePrefixType = function () {