DanielXMoore / Civet

A TypeScript superset that favors more types and less typing
https://civet.dev
MIT License
1.55k stars 33 forks source link

Expressionize statements followed by trailing member access/call or pipe #1375

Closed edemaine closed 2 months ago

edemaine commented 2 months ago

Fixes #1168 in a surprisingly simple way: don't parse if/switch/try/iterations as Statements if they're followed by an AllowedTrailingCallExpression or Pipe operator, leaving them to be parsed as expressions later on.

Also found a simpler way to avoid async do and async for from being parsed as calls to a function async: swapping the order so that ExpressionizedStatement gets checked before UpdateExpression (which includes CallExpression). This brings these into alignment with async function and so on which had no special handling. (This was also a necessary step; the workaround from before didn't work with the rest of this PR.)