diff options
| author | 2022-09-03 01:39:24 -0700 | |
|---|---|---|
| committer | 2022-09-03 01:39:24 -0700 | |
| commit | 8b2d07e82ee6249e0886109585b63429ccf3ab3a (patch) | |
| tree | 6ce7ca76c43ab1f540eafab0bc93fc62afd781cd | |
| parent | 3e9f7ab3e41e6035d6dedc19779799d1dfa67cfa (diff) | |
| download | bun-8b2d07e82ee6249e0886109585b63429ccf3ab3a.tar.gz bun-8b2d07e82ee6249e0886109585b63429ccf3ab3a.tar.zst bun-8b2d07e82ee6249e0886109585b63429ccf3ab3a.zip | |
fixed is_export and added test cases (#1203)
| -rw-r--r-- | src/js_parser.zig | 1 | ||||
| -rw-r--r-- | test/bun.js/transpiler.test.js | 62 |
2 files changed, 62 insertions, 1 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig index 4866954e4..a69db9db4 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -17079,7 +17079,6 @@ fn NewParser_( S.Local{ .kind = .k_let, .decls = decls, - .is_export = is_export, }, stmt_loc, ), diff --git a/test/bun.js/transpiler.test.js b/test/bun.js/transpiler.test.js index 51e1e669d..3bb458697 100644 --- a/test/bun.js/transpiler.test.js +++ b/test/bun.js/transpiler.test.js @@ -96,6 +96,68 @@ describe("Bun.Transpiler", () => { }); }); + describe("generated closures", () => { + const input1 = `namespace test { + export enum x { y } +}`; + const output1 = `var test; +(function(test) { + let x; + (function(x) { + x[x["y"] = 0] = "y"; + })(x = test.x || (test.x = {})); +})(test || (test = {}))`; + + it("namespace with exported enum", () => { + ts.expectPrinted_(input1, output1); + }); + + const input2 = `export namespace test { + export enum x { y } +}`; + const output2 = `export var test; +(function(test) { + let x; + (function(x) { + x[x["y"] = 0] = "y"; + })(x = test.x || (test.x = {})); +})(test || (test = {}))`; + + it("exported namespace with exported enum", () => { + ts.expectPrinted_(input2, output2); + }); + + const input3 = `namespace first { + export namespace second { + enum x { y } + } +}`; + const output3 = `var first; +(function(first) { + let second; + (function(second) { + let x; + (function(x) { + x[x["y"] = 0] = "y"; + })(x || (x = {})); + })(second = first.second || (first.second = {})); +})(first || (first = {}))` + + it("exported inner namespace", () => { + ts.expectPrinted_(input3, output3); + }); + + const input4 = `export enum x { y }` + const output4 = `export var x; +(function(x) { + x[x["y"] = 0] = "y"; +})(x || (x = {}))` + + it("exported enum", () => { + ts.expectPrinted_(input4, output4); + }); + }) + describe("exports.replace", () => { const transpiler = new Bun.Transpiler({ exports: { |
