BigInt type for Flow (#10091)

* flow BigIntLiteralTypeAnnotation

* numericSeparator for flow test plugins

* fix flow tuple

* fix code review
This commit is contained in:
Tan Li Hau
2019-07-03 22:48:46 +08:00
committed by Nicolò Ribaudo
parent cbb482e2f9
commit f588e4ec47
4 changed files with 31 additions and 25 deletions

View File

@@ -1263,7 +1263,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
});
case tt.bracketL:
return this.flowParseTupleType();
this.state.noAnonFunctionType = false;
type = this.flowParseTupleType();
this.state.noAnonFunctionType = oldNoAnonFunctionType;
return type;
case tt.relational:
if (this.state.value === "<") {
@@ -1352,15 +1355,27 @@ export default (superClass: Class<Parser>): Class<Parser> =>
case tt.plusMin:
if (this.state.value === "-") {
this.next();
if (!this.match(tt.num)) {
this.unexpected(null, `Unexpected token, expected "number"`);
if (this.match(tt.num)) {
return this.parseLiteral(
-this.state.value,
"NumberLiteralTypeAnnotation",
node.start,
node.loc.start,
);
}
return this.parseLiteral(
-this.state.value,
"NumberLiteralTypeAnnotation",
node.start,
node.loc.start,
if (this.match(tt.bigint)) {
return this.parseLiteral(
-this.state.value,
"BigIntLiteralTypeAnnotation",
node.start,
node.loc.start,
);
}
this.unexpected(
null,
`Unexpected token, expected "number" or "bigint"`,
);
}
@@ -1371,6 +1386,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
"NumberLiteralTypeAnnotation",
);
case tt.bigint:
return this.parseLiteral(
this.state.value,
"BigIntLiteralTypeAnnotation",
);
case tt._void:
this.next();
return this.finishNode(node, "VoidTypeAnnotation");

View File

@@ -1,3 +1,3 @@
{
"throws": "Unexpected token, expected \"number\" (1:8)"
"throws": "Unexpected token, expected \"number\" or \"bigint\" (1:8)"
}