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:
committed by
Henry Zhu
parent
39447b1cca
commit
a9a55fbd3f
4
test/fixtures/flow/regression/issue-58-ambiguous/actual.js
vendored
Normal file
4
test/fixtures/flow/regression/issue-58-ambiguous/actual.js
vendored
Normal 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;
|
||||
3
test/fixtures/flow/regression/issue-58-ambiguous/options.json
vendored
Normal file
3
test/fixtures/flow/regression/issue-58-ambiguous/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate. (4:4)"
|
||||
}
|
||||
Reference in New Issue
Block a user