support negative numeric type literals - fixes T7450

This commit is contained in:
Sebastian McKenzie
2016-06-22 13:17:27 +01:00
parent 96a7eadbe4
commit ec0a349ec8
11 changed files with 919 additions and 0 deletions

View File

@@ -559,6 +559,18 @@ pp.flowParsePrimaryType = function () {
this.next();
return this.finishNode(node, "BooleanLiteralTypeAnnotation");
case tt.plusMin:
if (this.state.value === "-") {
this.next();
if (!this.match(tt.num)) this.unexpected();
node.value = -this.state.value;
this.addExtra(node, "rawValue", node.value);
this.addExtra(node, "raw", this.input.slice(this.state.start, this.state.end));
this.next();
return this.finishNode(node, "NumericLiteralTypeAnnotation");
}
case tt.num:
node.value = this.state.value;
this.addExtra(node, "rawValue", node.value);