mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
fix(parser): advance by enum scopes length during visiting (#23581)
### What does this PR do? Matches esbuild behavior. Fixes #23578 ### How did you verify your code works? Added a test.
This commit is contained in:
@@ -73,6 +73,10 @@ describe("Bun.Transpiler", () => {
|
||||
expect(ts.parsed(code, !out.endsWith(";\n"), false)).toBe(out);
|
||||
},
|
||||
|
||||
transpiledOutput: code => {
|
||||
return ts.parsed(code, false, false);
|
||||
},
|
||||
|
||||
expectPrintedMin_: (code, out) => {
|
||||
expect(ts.parsedMin(code, !out.endsWith(";\n"), false)).toBe(out);
|
||||
},
|
||||
@@ -322,6 +326,29 @@ describe("Bun.Transpiler", () => {
|
||||
err("enum [] { a }", 'Expected identifier but found "["');
|
||||
});
|
||||
|
||||
it("doesn't crash with functions assigned to enum values", () => {
|
||||
const exp = ts.expectPrinted_;
|
||||
|
||||
expect(
|
||||
ts.transpiledOutput(
|
||||
`
|
||||
enum ABC {
|
||||
A = () => {},
|
||||
}
|
||||
function foo() {}
|
||||
`,
|
||||
"hi",
|
||||
),
|
||||
).toMatchInlineSnapshot(`
|
||||
"var ABC;
|
||||
((ABC) => {
|
||||
ABC[ABC["A"] = () => {}] = "A";
|
||||
})(ABC ||= {});
|
||||
function foo() {}
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
||||
// TODO: fix all the cases that report generic "Parse error"
|
||||
it("types", () => {
|
||||
const exp = ts.expectPrinted_;
|
||||
|
||||
Reference in New Issue
Block a user