* fix(parser): performance issue due to debug code
* perf(parser): avoid optional chain in node constructor
The optional chains do not affect Babel 7 because they are transpiled.
* fix: disallow non-leading solo await
* add more test cases
* refactor: remove unused soloAwait state
* fix: disallow binary operator after solo await
* fix: respect [In] production parameter
* update babel-parser dts
* Fix TypeScript parser failing on async calls inside ternary consequent
When the TypeScript plugin encounters `async(a)` followed by `:` inside
a ternary consequent, it incorrectly treats `:` as a return type annotation
for an async arrow function, rather than the ternary separator.
For example, `true ? async(a) : b => b` should parse as a ternary with
`async(a)` as the consequent (a call expression) and `b => b` as the
alternate (an arrow function). Instead, babel tried to parse
`async(a): b => b` as an async arrow with return type `b`.
This commit:
- Adds an `inConditionalConsequent` state flag set during ternary
consequent parsing
- When the flag is active, `shouldParseAsyncArrow` no longer treats
`:` as a return type annotation start
- Resets the flag inside parenthesized expressions, so
`a ? (async(b): T => body) : c` still works correctly
Fixes#17547
* Address review: use this.next() instead of this.expect() and add tests from #17572
Since the `?` token is already verified at the start of parseConditional,
use `this.next()` to consume it instead of redundantly checking with
`this.expect()`. Also add additional conditional expression test fixtures
ported from #17572 to improve coverage of arrow/async ambiguity edge cases.
* Add expected output files for test fixtures from #17572
These test cases document known limitations of the current fix:
- arrow-ambiguity, arrow-like, arrow-param: Non-async arrow disambiguation
in ternary expressions (out of scope for this PR)
- async-call, async-call-3: Edge cases where async call parsing interacts
with nested arrow/paren contexts
* fix: replace throws expectations with output.json for async-call fixtures
The async-call and async-call-3 test fixtures had "throws" directives in
options.json expecting parse errors, but the parser fix now correctly
handles these cases. Replace with output.json files containing expected ASTs.
---------
Co-authored-by: Hanzo Dev <[email protected]>
* chore: update test case for shared options.json
* chore: test against eslint 10
* fix: remove program location adjustment for ESLint 10
* test: invoke ESLint 9 program loc adjustment on ts-estree tests
* chore: add eslint 9 test job
* remove test from allowlist
* chore: remove @types/eslint