Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js_parser/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O
decls: decls_slice,
});
}
let r = p.store_name_in_ref(raw)?;
let r = p.store_name_in_ref(raw2)?;
Comment thread
robobun marked this conversation as resolved.
Comment thread
robobun marked this conversation as resolved.
Comment thread
robobun marked this conversation as resolved.
break 'value p.new_expr(
E::Identifier {
ref_: r,
Expand Down
17 changes: 17 additions & 0 deletions test/bundler/transpiler/transpiler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3824,6 +3824,23 @@ console.log("boop");
expectCapturePrintedSnapshot(`for await (await using a of b) { c(a); a(c) }`);
});

it("await of the identifier 'using' is not an await using declaration", () => {
// "await using" only starts a declaration when followed by an identifier on
// the same line. Otherwise it's an "await" expression of the identifier "using".
expectPrinted_(
"async function f() { await using instanceof o }",
"async function f() {\n await using instanceof o;\n}",
);
expectPrinted_("async function f() { await using }", "async function f() {\n await using;\n}");
expectPrinted_("async function f() { await using\n x = 1 }", "async function f() {\n await using;\n x = 1;\n}");
expectPrinted_("async function f() { await using.foo() }", "async function f() {\n await using.foo();\n}");
expectPrinted_(
"async function f() { for (await using instanceof o;;); }",
"async function f() {\n for (await using instanceof o;; )\n ;\n}",
);
expectBunPrinted_("await using instanceof o", "await using instanceof o");
});

it("using top level", () => {
expectPrintedSnapshot(`
using a = b;
Expand Down
Loading