From 5f9f58838669bf4e665c6180fd32d0544f585d07 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sun, 18 Jan 2015 18:33:42 +1100 Subject: [PATCH] fix flow function param type parsing - allow optional notation as well as type declaration - fixes 6to5/6to5#524 --- acorn.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/acorn.js b/acorn.js index 90a75b3582..57c5245c77 100644 --- a/acorn.js +++ b/acorn.js @@ -3043,6 +3043,7 @@ defaults.push(null); } } + if (!eat(_comma)) { expect(_parenR); break; @@ -3058,10 +3059,11 @@ } function parseFunctionParam(param) { + if (eat(_question)) { + param.optional = true; + } if (tokType === _colon) { param.typeAnnotation = parseTypeAnnotation(); - } else if (eat(_question)) { - param.optional = true; } finishNode(param, param.type); }