Permit %%placeholder%% in left-hand-side of a let declaration (#12725)
* Permit %%placeholder%% in left-hand-side of a let declaration * Test that "let" followed by modulo is still treated as an identifier * More tests for edge-case handling of "let" with placeholders enabled
This commit is contained in:
@@ -393,5 +393,29 @@ describe("@babel/template", function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("works in var declaration", () => {
|
||||
const output = template("var %%LHS%% = %%RHS%%")({
|
||||
LHS: t.identifier("x"),
|
||||
RHS: t.numericLiteral(7),
|
||||
});
|
||||
expect(generator(output).code).toMatchInlineSnapshot(`"var x = 7;"`);
|
||||
});
|
||||
|
||||
it("works in const declaration", () => {
|
||||
const output = template("const %%LHS%% = %%RHS%%")({
|
||||
LHS: t.identifier("x"),
|
||||
RHS: t.numericLiteral(7),
|
||||
});
|
||||
expect(generator(output).code).toMatchInlineSnapshot(`"const x = 7;"`);
|
||||
});
|
||||
|
||||
it("works in let declaration", () => {
|
||||
const output = template("let %%LHS%% = %%RHS%%")({
|
||||
LHS: t.identifier("x"),
|
||||
RHS: t.numericLiteral(7),
|
||||
});
|
||||
expect(generator(output).code).toMatchInlineSnapshot(`"let x = 7;"`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user