Some function types fail to parse inside arrow functions #8942
Labels
area: flow
Has PR
i: bug
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
pkg: parser
Bug Report
Current Behavior
let x = (): (T) => U => 123
is a parse error, to avoid ambiguity/lookahead after the first=>
. Wrapping the return type in parens avoids the ambiguity:let x = (): ((T) => U) => 123
But it fails to parse when a function type is nested inside a generic, inside the return type (see below), even though that similarly delimits the nested function type.
Input Code
https://astexplorer.net/#/gist/af5836b64b734d2c74496bbcccec6f3e/305660c62c2d85a3475bf5df4e35fe40a3be29cc
Expected behavior/code
Should parse as a function type with an anonymous
string
param, inside anArray
generic type, inside the return type annotation of an arrow function.Environment
Possible Solution
See related Flow parser fix: facebook/flow@607e9fa
I'm not sure how it's implemented in Babylon, but I'm guessing the fix might be similar.
The text was updated successfully, but these errors were encountered: