Flow enums parsing (#10344)

* Flow enums parsing

* Parse exporting enums

* Enums parsing remove lookahead, other improvements

* Enums: add EnumBody and EnumMember aliases, change boolean members to use BooleaLiteral value

* Fix enum member init flow type, now that boolean members have a BooleanLiteral value

* Flow enums: use contextual utils, change members length checks to use logic operators, remove reserved word logic modification

* Flow enums: remove unnecessary code in generator, fix error message
This commit is contained in:
George Zahariev
2019-10-29 14:55:12 -07:00
committed by Nicolò Ribaudo
parent 4b3a19ea9f
commit ec3345bb57
92 changed files with 3213 additions and 5 deletions

View File

@@ -5,12 +5,16 @@ export default declare((api, options) => {
// When enabled and plugins includes flow, all files should be parsed as if
// the @flow pragma was provided.
const { all } = options;
const { all, enums } = options;
if (typeof all !== "boolean" && typeof all !== "undefined") {
throw new Error(".all must be a boolean, or undefined");
}
if (typeof enums !== "boolean" && typeof enums !== "undefined") {
throw new Error(".enums must be a boolean, or undefined");
}
return {
name: "syntax-flow",
@@ -25,7 +29,7 @@ export default declare((api, options) => {
return;
}
parserOpts.plugins.push(["flow", { all }]);
parserOpts.plugins.push(["flow", { all, enums }]);
},
};
});