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:
committed by
Daniel Tschinder
parent
6cb023590a
commit
01ed943deb
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user