Skip to content

Commit

Permalink
Fix minor formatting and docs issues
Browse files Browse the repository at this point in the history
  • Loading branch information
alangpierce committed Jun 28, 2023
1 parent b509898 commit 7341cce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/parser/traverser/statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ function parseStatementContent(declaration: boolean): void {
* Determine if we're positioned at an `await using` declaration.
*
* Note that this can happen either in place of a regular variable declaration
* or in a loop body, and in both places, there are
* or in a loop body, and in both places, there are similar-looking cases where
* we need to return false.
*
* Examples returning true:
* await using foo = bar();
Expand All @@ -275,9 +276,9 @@ function parseStatementContent(declaration: boolean): void {
* await using instanceof T
* for (await using;;) {}
*
* For now, we do a simple backtracking-based lookahead for the `using` and
* identifier tokens. In the future, this could be optimized with a
* character-based approach.
* For now, we early return if we don't see `await`, then do a simple
* backtracking-based lookahead for the `using` and identifier tokens. In the
* future, this could be optimized with a character-based approach.
*/
function startsAwaitUsing(): boolean {
if (!isContextual(ContextualKeyword._await)) {
Expand Down
3 changes: 2 additions & 1 deletion test/sucrase-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,7 @@ describe("sucrase", () => {
{transforms: []},
);
});

it("correctly handles `await using` in a loop", () => {
assertResult(
`
Expand All @@ -1812,7 +1813,7 @@ describe("sucrase", () => {
);
});

it("is not confused `await using` in other contexts", () => {
it("is not confused by `await using` in other contexts", () => {
assertResult(
`
await using
Expand Down

0 comments on commit 7341cce

Please sign in to comment.