Distinguish between ternary's : and arrow fn's return type (#573)

* Distinguish between ternary's : and arrow fn's return type

* Correctly parse nested arrow functions inside conditional expressions

Defer the conversion of arrow function parameters to assignable nodes so that
it is possible to use the (invalid) ast to get the exact position of the (wrong)
arrow functions.

* Check params of arrow fns w/ type params or w/o return type

* Fix also async functions

* Add test from prettier

https://github.com/prettier/prettier/issues/2194

* Don't check arrow params if they are valid at the first attemp

* Use state instead of relying on the "noArrowParamsConversion" parameter

* Remove noArrowParamsConversion
This commit is contained in:
Nicolò Ribaudo
2017-06-27 21:44:56 +02:00
committed by Henry Zhu
parent 39447b1cca
commit a9a55fbd3f
15 changed files with 6840 additions and 10 deletions

View File

@@ -0,0 +1,4 @@
// This can be parsed in two ways:
// a ? b : (c => ((d): e => f))
// a ? ((b): c => d) : (e => f)
a ? (b) : c => (d) : e => f;

View File

@@ -0,0 +1,3 @@
{
"throws": "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate. (4:4)"
}