flow - allow type parameter defaults in function declarations (#10084)

* flow - allow type parameter defaults in function declarations

* fix flow test

* add intern_comments option

* fix flow parser test

* remove allowdefault from flowParseTypeParameterDeclaration

* rename test cases
This commit is contained in:
Tan Li Hau
2019-06-15 18:31:12 +08:00
committed by Nicolò Ribaudo
parent 6852bf6415
commit fdbbb743b6
22 changed files with 938 additions and 74 deletions

View File

@@ -113,7 +113,10 @@ const options = {
["flow", { all: true }],
"flowComments",
"jsx",
"classProperties",
"classPrivateProperties",
"classPrivateMethods",
"bigInt",
],
sourceType: "module",
ranges: true,
@@ -127,6 +130,7 @@ const flowOptionsMapping = {
esproposal_nullish_coalescing: "nullishCoalescingOperator",
esproposal_optional_chaining: "optionalChaining",
types: "flowComments",
intern_comments: false,
};
const summary = {
@@ -169,10 +173,12 @@ tests.forEach(section => {
}
return;
}
if (!flowOptionsMapping[option]) {
if (!(option in flowOptionsMapping)) {
throw new Error("Parser options not mapped " + option);
}
babelParserOptions.plugins.push(flowOptionsMapping[option]);
if (flowOptionsMapping[option]) {
babelParserOptions.plugins.push(flowOptionsMapping[option]);
}
});
}