Original issue submitted by @jrajav in babel/babel#5191
Annotating a function type in Flowtype with a default parameter (which looks like ?Type) seems to cause a parsing error in the current version of Babel, ^6.21. This could be a regression of babel/babel#2493.
Input Code
const fn: ( Object, ?Object ) => void = ( o1, o2 ) => o1
https://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-2&code=const%20fn%3A%20(%20Object%2C%20%3FObject%20)%20%3D%3E%20void%20%3D%20(%20o1%2C%20o2%20)%20%3D%3E%20o1
Babel Configuration (.babelrc, package.json, cli command)
NOTE: Fails on REPL too so probably irrelevant, see link above. Included anyway just in case:
{
"presets": [
"es2015",
"react"
],
"plugins": [
"react-hot-loader/babel",
"ramda",
["babel-root-slash-import", {
"rootPathSuffix": "src"
}],
["extensible-destructuring", {
"mode": "optout",
"impl": "immutable"
}]
],
"env": {
"test": {
"plugins": [
"istanbul"
]
}
}
}
Expected Behavior
The code parses successfully.
Current Behavior
A parsing error occurs at the default parameter Flow annotation:
Unexpected token, expected ) (1:20)
> 1 | const fn: ( Object, ?Object ) => void = ( o1, o2 ) => o1