Skip to content

Commit

Permalink
flow BigIntLiteralTypeAnnotation
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau committed Jun 13, 2019
1 parent 445cd2a commit 9bd68f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
31 changes: 23 additions & 8 deletions packages/babel-parser/src/plugins/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -1370,16 +1370,25 @@ 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"`);
}

this.unexpected();
Expand All @@ -1389,6 +1398,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");
Expand Down
9 changes: 0 additions & 9 deletions scripts/tests/flow/flow_tests_whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ private_class_properties/getter_duplicate.js
private_class_properties/setter_and_field.js
private_class_properties/setter_duplicate.js
types/member/reserved_words.js
types/bigint_literal/migrated_0000.js
types/bigint_literal/migrated_0002.js
types/bigint_literal/migrated_0003.js
types/bigint_literal/migrated_0004.js
types/bigint_literal/migrated_0005.js
types/bigint_literal/migrated_0006.js
types/bigint_literal/migrated_0007.js
types/bigint_literal/migrated_0008.js
types/bigint_literal/migrated_0009.js
class_method_kinds/polymorphic_getter.js
numbers/underscored_bin.js
numbers/underscored_float.js
Expand Down

0 comments on commit 9bd68f2

Please sign in to comment.