From 8a192018247ad7ac253c2964038de5f626acb8c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 15 Oct 2024 23:12:50 +0900 Subject: [PATCH] fix(es): Run esnext transforms on esnext target (#9644) **Related issue:** - Closes /~https://github.com/swc-project/swc/issues/9640 - Closes /~https://github.com/swc-project/swc/issues/9641 --- .changeset/beige-moles-grow.md | 6 + crates/swc/src/config/mod.rs | 17 +- crates/swc/tests/exec.rs | 1 + .../fixture/issues-9xxx/9640/input/.swcrc | 25 + .../tests/fixture/issues-9xxx/9640/input/1.js | 12 + .../fixture/issues-9xxx/9640/output/1.js | 17 + .../fixture/issues-9xxx/9641/input/.swcrc | 25 + .../tests/fixture/issues-9xxx/9641/input/1.js | 3 + .../fixture/issues-9xxx/9641/output/1.js | 6 + ...gDeclarations.1(target=esnext).1.normal.js | 365 ++++++++---- ...eclarations.1(target=esnext).2.minified.js | 194 +++++-- .../awaitUsingDeclarations.12.1.normal.js | 11 +- .../awaitUsingDeclarations.12.2.minified.js | 1 + .../awaitUsingDeclarations.13.1.normal.js | 22 +- .../awaitUsingDeclarations.13.2.minified.js | 10 +- .../awaitUsingDeclarations.15.1.normal.js | 13 +- .../awaitUsingDeclarations.15.2.minified.js | 1 + ...gDeclarations.2(target=esnext).1.normal.js | 17 +- ...eclarations.2(target=esnext).2.minified.js | 17 +- ...gDeclarations.3(target=esnext).1.normal.js | 17 +- ...eclarations.3(target=esnext).2.minified.js | 17 +- .../awaitUsingDeclarations.9.1.normal.js | 11 +- .../awaitUsingDeclarations.9.2.minified.js | 11 +- ...onsInForAwaitOf(target=esnext).1.normal.js | 14 +- ...sInForAwaitOf(target=esnext).2.minified.js | 1 + ...ationsInForOf.1(target=esnext).1.normal.js | 14 +- ...ionsInForOf.1(target=esnext).2.minified.js | 1 + ...lChainWithSuper(target=esnext).1.normal.js | 13 + ...hainWithSuper(target=esnext).2.minified.js | 1 + .../decoratorOnClassMethod14.1.normal.js | 9 +- .../decoratorOnClassMethod14.2.minified.js | 15 + .../decoratorOnClassMethod15.1.normal.js | 9 +- .../decoratorOnClassMethod15.2.minified.js | 15 + .../decoratorOnClassMethod16.1.normal.js | 9 +- .../decoratorOnClassMethod16.2.minified.js | 12 + .../decoratorOnClassMethod18.1.normal.js | 4 + .../decoratorOnClassMethod18.2.minified.js | 5 + ...StaticMembers10(target=esnext).1.normal.js | 9 +- ...aticMembers10(target=esnext).2.minified.js | 9 +- ...StaticMembers11(target=esnext).1.normal.js | 9 +- ...aticMembers11(target=esnext).2.minified.js | 9 +- ...gDeclarations.1(target=esnext).1.normal.js | 548 ++++++++++++------ ...eclarations.1(target=esnext).2.minified.js | 347 ++++++++--- .../usingDeclarations.14.1.normal.js | 10 +- .../usingDeclarations.14.2.minified.js | 10 +- .../usingDeclarations.15.1.normal.js | 12 +- .../usingDeclarations.15.2.minified.js | 13 +- ...gDeclarations.2(target=esnext).1.normal.js | 17 +- ...eclarations.2(target=esnext).2.minified.js | 16 +- ...gDeclarations.3(target=esnext).1.normal.js | 17 +- ...eclarations.3(target=esnext).2.minified.js | 16 +- .../usingDeclarations.9.1.normal.js | 11 +- .../usingDeclarations.9.2.minified.js | 10 +- ...gDeclarationsDeclarationEmit.1.1.normal.js | 20 +- ...eclarationsDeclarationEmit.1.2.minified.js | 16 +- ...gDeclarationsDeclarationEmit.2.1.normal.js | 18 +- ...eclarationsDeclarationEmit.2.2.minified.js | 18 +- ...onsInForAwaitOf(target=esnext).1.normal.js | 14 +- ...sInForAwaitOf(target=esnext).2.minified.js | 1 + ...ationsInForOf.1(target=esnext).1.normal.js | 14 +- ...ionsInForOf.1(target=esnext).2.minified.js | 11 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 15 +- ...rs.1(module=es6,target=esnext).1.normal.js | 17 +- ....1(module=es6,target=esnext).2.minified.js | 17 +- ...1(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 29 +- ...module=commonjs,target=esnext).1.normal.js | 19 +- ...dule=commonjs,target=esnext).2.minified.js | 16 +- ...s.10(module=es6,target=esnext).1.normal.js | 18 +- ...10(module=es6,target=esnext).2.minified.js | 16 +- ...0(module=system,target=esnext).1.normal.js | 32 +- ...module=system,target=esnext).2.minified.js | 31 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 15 +- ...s.11(module=es6,target=esnext).1.normal.js | 19 +- ...11(module=es6,target=esnext).2.minified.js | 16 +- ...1(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 31 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 15 +- ...s.12(module=es6,target=esnext).1.normal.js | 19 +- ...12(module=es6,target=esnext).2.minified.js | 16 +- ...2(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 31 +- ...module=commonjs,target=esnext).1.normal.js | 21 +- ...dule=commonjs,target=esnext).2.minified.js | 18 +- ...rs.2(module=es6,target=esnext).1.normal.js | 20 +- ....2(module=es6,target=esnext).2.minified.js | 18 +- ...2(module=system,target=esnext).1.normal.js | 34 +- ...module=system,target=esnext).2.minified.js | 32 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 16 +- ...rs.3(module=es6,target=esnext).1.normal.js | 18 +- ....3(module=es6,target=esnext).2.minified.js | 18 +- ...3(module=system,target=esnext).1.normal.js | 34 +- ...module=system,target=esnext).2.minified.js | 34 +- ...module=commonjs,target=esnext).1.normal.js | 19 +- ...dule=commonjs,target=esnext).2.minified.js | 18 +- ...rs.4(module=es6,target=esnext).1.normal.js | 18 +- ....4(module=es6,target=esnext).2.minified.js | 18 +- ...4(module=system,target=esnext).1.normal.js | 32 +- ...module=system,target=esnext).2.minified.js | 33 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 16 +- ...rs.5(module=es6,target=esnext).1.normal.js | 19 +- ....5(module=es6,target=esnext).2.minified.js | 17 +- ...5(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 32 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 16 +- ...rs.6(module=es6,target=esnext).1.normal.js | 19 +- ....6(module=es6,target=esnext).2.minified.js | 17 +- ...6(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 32 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 14 +- ...rs.7(module=es6,target=esnext).1.normal.js | 17 +- ....7(module=es6,target=esnext).2.minified.js | 16 +- ...7(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 28 +- ...module=commonjs,target=esnext).1.normal.js | 21 +- ...dule=commonjs,target=esnext).2.minified.js | 17 +- ...rs.8(module=es6,target=esnext).1.normal.js | 20 +- ....8(module=es6,target=esnext).2.minified.js | 17 +- ...8(module=system,target=esnext).1.normal.js | 34 +- ...module=system,target=esnext).2.minified.js | 31 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 14 +- ...rs.9(module=es6,target=esnext).1.normal.js | 18 +- ....9(module=es6,target=esnext).2.minified.js | 16 +- ...9(module=system,target=esnext).1.normal.js | 34 +- ...module=system,target=esnext).2.minified.js | 32 +- crates/swc/tests/tsc.rs | 4 +- 134 files changed, 2861 insertions(+), 863 deletions(-) create mode 100644 .changeset/beige-moles-grow.md create mode 100644 crates/swc/tests/fixture/issues-9xxx/9640/input/.swcrc create mode 100644 crates/swc/tests/fixture/issues-9xxx/9640/input/1.js create mode 100644 crates/swc/tests/fixture/issues-9xxx/9640/output/1.js create mode 100644 crates/swc/tests/fixture/issues-9xxx/9641/input/.swcrc create mode 100644 crates/swc/tests/fixture/issues-9xxx/9641/input/1.js create mode 100644 crates/swc/tests/fixture/issues-9xxx/9641/output/1.js create mode 100644 crates/swc/tests/tsc-references/callChainWithSuper(target=esnext).1.normal.js create mode 100644 crates/swc/tests/tsc-references/callChainWithSuper(target=esnext).2.minified.js diff --git a/.changeset/beige-moles-grow.md b/.changeset/beige-moles-grow.md new file mode 100644 index 000000000000..654e2d505a9d --- /dev/null +++ b/.changeset/beige-moles-grow.md @@ -0,0 +1,6 @@ +--- +swc: patch +swc_core: patch +--- + +fix(es): Run esnext transforms on esnext target diff --git a/crates/swc/src/config/mod.rs b/crates/swc/src/config/mod.rs index 7154208ba942..d44524b61d30 100644 --- a/crates/swc/src/config/mod.rs +++ b/crates/swc/src/config/mod.rs @@ -74,9 +74,7 @@ use swc_ecma_visit::{Fold, VisitMutWith}; pub use crate::plugin::PluginConfig; use crate::{ - builder::{should_enable, PassBuilder}, - dropped_comments_preserver::dropped_comments_preserver, - SwcImportResolver, + builder::PassBuilder, dropped_comments_preserver::dropped_comments_preserver, SwcImportResolver, }; #[cfg(test)] @@ -712,21 +710,14 @@ impl Options { !disable_all_lints ), // Decorators may use type information - Optional::new( - decorator_pass, - should_enable(es_version, EsVersion::EsNext) && syntax.decorators() - ), + Optional::new(decorator_pass, syntax.decorators()), Optional::new( explicit_resource_management(), - should_enable(es_version, EsVersion::EsNext) - && syntax.explicit_resource_management() + syntax.explicit_resource_management() ), // The transform strips import assertions, so it's only enabled if // keep_import_assertions is false. - Optional::new( - import_assertions(), - should_enable(es_version, EsVersion::EsNext) && !keep_import_attributes - ), + Optional::new(import_assertions(), !keep_import_attributes), Optional::new( typescript::tsx::>( cm.clone(), diff --git a/crates/swc/tests/exec.rs b/crates/swc/tests/exec.rs index 4104d54d3a84..8af947d2f2ed 100644 --- a/crates/swc/tests/exec.rs +++ b/crates/swc/tests/exec.rs @@ -117,6 +117,7 @@ fn create_matrix(entry: &Path) -> Vec { .unwrap_or_default(); [ + EsVersion::EsNext, EsVersion::Es2022, EsVersion::Es2021, EsVersion::Es2020, diff --git a/crates/swc/tests/fixture/issues-9xxx/9640/input/.swcrc b/crates/swc/tests/fixture/issues-9xxx/9640/input/.swcrc new file mode 100644 index 000000000000..8a52e8eb730e --- /dev/null +++ b/crates/swc/tests/fixture/issues-9xxx/9640/input/.swcrc @@ -0,0 +1,25 @@ +{ + "$schema": "https://swc.rs/schema.json", + "module": { + "type": "es6" + }, + "jsc": { + "target": "esnext", + "parser": { + "syntax": "typescript", + "decorators": true, + "importAssertions": true + }, + "transform": { + "legacyDecorator": true, + "decoratorMetadata": true, + "useDefineForClassFields": true + }, + "keepClassNames": true, + "experimental": { + "keepImportAttributes": true, + "emitAssertForImportAttributes": false + } + }, + "minify": false +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-9xxx/9640/input/1.js b/crates/swc/tests/fixture/issues-9xxx/9640/input/1.js new file mode 100644 index 000000000000..045de134159a --- /dev/null +++ b/crates/swc/tests/fixture/issues-9xxx/9640/input/1.js @@ -0,0 +1,12 @@ +function computed() { + return function (target) { + console.log(target) + } +} + +class User { + @computed() + get fullName() { + return 'foo' + } +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-9xxx/9640/output/1.js b/crates/swc/tests/fixture/issues-9xxx/9640/output/1.js new file mode 100644 index 000000000000..2f11465a5520 --- /dev/null +++ b/crates/swc/tests/fixture/issues-9xxx/9640/output/1.js @@ -0,0 +1,17 @@ +var _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +var _ts_metadata = require("@swc/helpers/_/_ts_metadata"); +function computed() { + return function(target) { + console.log(target); + }; +} +let User = class User { + get fullName() { + return 'foo'; + } +}; +_ts_decorate._([ + computed(), + _ts_metadata._("design:type", void 0), + _ts_metadata._("design:paramtypes", []) +], User.prototype, "fullName", null); diff --git a/crates/swc/tests/fixture/issues-9xxx/9641/input/.swcrc b/crates/swc/tests/fixture/issues-9xxx/9641/input/.swcrc new file mode 100644 index 000000000000..725856333e84 --- /dev/null +++ b/crates/swc/tests/fixture/issues-9xxx/9641/input/.swcrc @@ -0,0 +1,25 @@ +{ + "$schema": "https://swc.rs/schema.json", + "module": { + "type": "es6" + }, + "jsc": { + "target": "es2015", + "parser": { + "syntax": "typescript", + "decorators": true, + "importAssertions": true + }, + "transform": { + "legacyDecorator": true, + "decoratorMetadata": true, + "useDefineForClassFields": true + }, + "keepClassNames": true, + "experimental": { + "keepImportAttributes": true, + "emitAssertForImportAttributes": false + } + }, + "minify": false +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-9xxx/9641/input/1.js b/crates/swc/tests/fixture/issues-9xxx/9641/input/1.js new file mode 100644 index 000000000000..6125e8db5541 --- /dev/null +++ b/crates/swc/tests/fixture/issues-9xxx/9641/input/1.js @@ -0,0 +1,3 @@ +@Injectable() +export class MyService { } + diff --git a/crates/swc/tests/fixture/issues-9xxx/9641/output/1.js b/crates/swc/tests/fixture/issues-9xxx/9641/output/1.js new file mode 100644 index 000000000000..a8aad88d6db9 --- /dev/null +++ b/crates/swc/tests/fixture/issues-9xxx/9641/output/1.js @@ -0,0 +1,6 @@ +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +export class MyService { +} +MyService = _ts_decorate([ + Injectable() +], MyService); diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).1.normal.js index 8e75384df4b8..f4fb101df113 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).1.normal.js @@ -1,138 +1,267 @@ //// [awaitUsingDeclarations.1.ts] -await using d1 = { - async [Symbol.asyncDispose] () {} -} -async function af() { - await using d3 = { - async [Symbol.asyncDispose] () {} - } - ; - await null; -} -async function* ag() { - await using d5 = { - async [Symbol.asyncDispose] () {} - } - ; - yield; - await null; -} -const a = async ()=>{ - await using d6 = { +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + var d1 = _usingCtx.a({ async [Symbol.asyncDispose] () {} + }); + async function af() { + try { + var _usingCtx = _using_ctx(); + const d3 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); + await null; + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); + } } - ; -}; -class C1 { - async am() { - await using d13 = { - async [Symbol.asyncDispose] () {} - } - ; - await null; - } - async *ag() { - await using d15 = { - async [Symbol.asyncDispose] () {} + async function* ag() { + try { + var _usingCtx = _using_ctx(); + const d5 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); + yield; + await null; + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); } - ; - yield; - await null; } - constructor(){ - this.a = async ()=>{ - await using d7 = { + const a = async ()=>{ + try { + var _usingCtx = _using_ctx(); + const d6 = _usingCtx.a({ async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); + } + }; + class C1 { + async am() { + try { + var _usingCtx = _using_ctx(); + const d13 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); + await null; + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); } - ; - }; - } -} -{ - await using d19 = { - async [Symbol.asyncDispose] () {} - } - ; -}switch(Math.random()){ - case 0: - await using d20 = { - async [Symbol.asyncDispose] () {} - } - ; - break; - case 1: - await using d21 = { - async [Symbol.asyncDispose] () {} - } - ; - break; -} -if (true) switch(0){ - case 0: - await using d22 = { - async [Symbol.asyncDispose] () {} } - ; - break; -} -try { - await using d23 = { - async [Symbol.asyncDispose] () {} + async *ag() { + try { + var _usingCtx = _using_ctx(); + const d15 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); + yield; + await null; + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); + } + } + constructor(){ + this.a = async ()=>{ + try { + var _usingCtx = _using_ctx(); + const d7 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); + } + }; + } } - ; -} catch { - await using d24 = { - async [Symbol.asyncDispose] () {} + { + try { + var _usingCtx1 = _using_ctx(); + const d19 = _usingCtx1.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx1.e = _; + } finally{ + await _usingCtx1.d(); + } } - ; -} finally{ - await using d25 = { - async [Symbol.asyncDispose] () {} + switch(Math.random()){ + case 0: + try { + var _usingCtx2 = _using_ctx(); + const d20 = _usingCtx2.a({ + async [Symbol.asyncDispose] () {} + }); + break; + } catch (_) { + _usingCtx2.e = _; + } finally{ + await _usingCtx2.d(); + } + case 1: + try { + var _usingCtx3 = _using_ctx(); + const d21 = _usingCtx3.a({ + async [Symbol.asyncDispose] () {} + }); + break; + } catch (_) { + _usingCtx3.e = _; + } finally{ + await _usingCtx3.d(); + } } - ; -} -if (true) { - await using d26 = { - async [Symbol.asyncDispose] () {} + if (true) switch(0){ + case 0: + try { + var _usingCtx4 = _using_ctx(); + const d22 = _usingCtx4.a({ + async [Symbol.asyncDispose] () {} + }); + break; + } catch (_) { + _usingCtx4.e = _; + } finally{ + await _usingCtx4.d(); + } } - ; -} else { - await using d27 = { - async [Symbol.asyncDispose] () {} + try { + try { + var _usingCtx5 = _using_ctx(); + const d23 = _usingCtx5.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx5.e = _; + } finally{ + await _usingCtx5.d(); + } + } catch { + try { + var _usingCtx6 = _using_ctx(); + const d24 = _usingCtx6.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx6.e = _; + } finally{ + await _usingCtx6.d(); + } + } finally{ + try { + var _usingCtx7 = _using_ctx(); + const d25 = _usingCtx7.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx7.e = _; + } finally{ + await _usingCtx7.d(); + } } - ; -} -while(true){ - await using d28 = { - async [Symbol.asyncDispose] () {} + if (true) { + try { + var _usingCtx8 = _using_ctx(); + const d26 = _usingCtx8.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx8.e = _; + } finally{ + await _usingCtx8.d(); + } + } else { + try { + var _usingCtx9 = _using_ctx(); + const d27 = _usingCtx9.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx9.e = _; + } finally{ + await _usingCtx9.d(); + } } - ; - break; -} -do { - await using d29 = { - async [Symbol.asyncDispose] () {} + while(true){ + try { + var _usingCtx10 = _using_ctx(); + const d28 = _usingCtx10.a({ + async [Symbol.asyncDispose] () {} + }); + break; + } catch (_) { + _usingCtx10.e = _; + } finally{ + await _usingCtx10.d(); + } } - ; - break; -}while (true) -for(;;){ - await using d30 = { - async [Symbol.asyncDispose] () {} + do { + try { + var _usingCtx11 = _using_ctx(); + const d29 = _usingCtx11.a({ + async [Symbol.asyncDispose] () {} + }); + break; + } catch (_) { + _usingCtx11.e = _; + } finally{ + await _usingCtx11.d(); + } + }while (true) + for(;;){ + try { + var _usingCtx12 = _using_ctx(); + const d30 = _usingCtx12.a({ + async [Symbol.asyncDispose] () {} + }); + break; + } catch (_) { + _usingCtx12.e = _; + } finally{ + await _usingCtx12.d(); + } } - ; - break; -} -for(const x in {}){ - await using d31 = { - async [Symbol.asyncDispose] () {} + for(const x in {}){ + try { + var _usingCtx13 = _using_ctx(); + const d31 = _usingCtx13.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx13.e = _; + } finally{ + await _usingCtx13.d(); + } } - ; -} -for (const x of []){ - await using d32 = { - async [Symbol.asyncDispose] () {} + for (const x of []){ + try { + var _usingCtx14 = _using_ctx(); + const d32 = _usingCtx14.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx14.e = _; + } finally{ + await _usingCtx14.d(); + } } - ; +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); } export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).2.minified.js index a24672f1aec9..db8011a13132 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).2.minified.js @@ -1,62 +1,154 @@ //// [awaitUsingDeclarations.1.ts] -await using d1 = { - async [Symbol.asyncDispose] () {} -} -await using d19 = { - async [Symbol.asyncDispose] () {} -} -switch(Math.random()){ - case 0: - await using d20 = { +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); + try { + var _usingCtx1 = _using_ctx(); + _usingCtx1.a({ async [Symbol.asyncDispose] () {} - } - break; - case 1: - await using d21 = { + }); + } catch (_) { + _usingCtx1.e = _; + } finally{ + await _usingCtx1.d(); + } + switch(Math.random()){ + case 0: + try { + var _usingCtx2 = _using_ctx(); + _usingCtx2.a({ + async [Symbol.asyncDispose] () {} + }); + break; + } catch (_) { + _usingCtx2.e = _; + } finally{ + await _usingCtx2.d(); + } + case 1: + try { + var _usingCtx3 = _using_ctx(); + _usingCtx3.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx3.e = _; + } finally{ + await _usingCtx3.d(); + } + } + try { + var _usingCtx4 = _using_ctx(); + _usingCtx4.a({ async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx4.e = _; + } finally{ + await _usingCtx4.d(); + } + try { + try { + var _usingCtx5 = _using_ctx(); + _usingCtx5.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx5.e = _; + } finally{ + await _usingCtx5.d(); + } + } catch { + try { + var _usingCtx6 = _using_ctx(); + _usingCtx6.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx6.e = _; + } finally{ + await _usingCtx6.d(); + } + } finally{ + try { + var _usingCtx7 = _using_ctx(); + _usingCtx7.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx7.e = _; + } finally{ + await _usingCtx7.d(); } -} -await using d22 = { - async [Symbol.asyncDispose] () {} -} -try { - await using d23 = { - async [Symbol.asyncDispose] () {} } -} catch { - await using d24 = { - async [Symbol.asyncDispose] () {} + try { + var _usingCtx8 = _using_ctx(); + _usingCtx8.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx8.e = _; + } finally{ + await _usingCtx8.d(); } -} finally{ - await using d25 = { - async [Symbol.asyncDispose] () {} + for(;;)try { + var _usingCtx10 = _using_ctx(); + _usingCtx10.a({ + async [Symbol.asyncDispose] () {} + }); + break; + } catch (_) { + _usingCtx10.e = _; + } finally{ + await _usingCtx10.d(); } -} -await using d26 = { - async [Symbol.asyncDispose] () {} -} -for(;;){ - await using d28 = { - async [Symbol.asyncDispose] () {} + for(;;)try { + var _usingCtx11 = _using_ctx(); + _usingCtx11.a({ + async [Symbol.asyncDispose] () {} + }); + break; + } catch (_) { + _usingCtx11.e = _; + } finally{ + await _usingCtx11.d(); } - break; -} -for(;;){ - await using d29 = { - async [Symbol.asyncDispose] () {} + for(;;)try { + var _usingCtx12 = _using_ctx(); + _usingCtx12.a({ + async [Symbol.asyncDispose] () {} + }); + break; + } catch (_) { + _usingCtx12.e = _; + } finally{ + await _usingCtx12.d(); } - break; -} -for(;;){ - await using d30 = { - async [Symbol.asyncDispose] () {} + for(let x in {})try { + var _usingCtx13 = _using_ctx(); + _usingCtx13.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx13.e = _; + } finally{ + await _usingCtx13.d(); } - break; -} -for(let x in {})await using d31 = { - async [Symbol.asyncDispose] () {} -} -for (let x of [])await using d32 = { - async [Symbol.asyncDispose] () {} + for (let x of [])try { + var _usingCtx14 = _using_ctx(); + _usingCtx14.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx14.e = _; + } finally{ + await _usingCtx14.d(); + } +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); } -export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.1.normal.js index 42dce7c9dbe5..015814bfd05a 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.1.normal.js @@ -1,5 +1,12 @@ //// [awaitUsingDeclarations.12.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; async function f() { - await using x = {} - ; + try { + var _usingCtx = _using_ctx(); + const x = _usingCtx.a({}); + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); + } } diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.2.minified.js index b20fa1fa672f..aab4b1d8155a 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.2.minified.js @@ -1 +1,2 @@ //// [awaitUsingDeclarations.12.ts] +import "@swc/helpers/_/_using_ctx"; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.1.normal.js index a704b8831a61..5c4f259e5fe0 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.1.normal.js @@ -1,6 +1,20 @@ //// [awaitUsingDeclarations.13.ts] -await using x = null -function f() { - await using x = null - ; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + var x = _usingCtx.a(null); + function f() { + try { + var _usingCtx = _using_ctx(); + const x = _usingCtx.a(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); + } + } +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.2.minified.js index b28c4ffd4093..5ae54041146f 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.2.minified.js @@ -1,2 +1,10 @@ //// [awaitUsingDeclarations.13.ts] -await using x = null +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.a(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.1.normal.js index 13ec252e4e62..9790c4791081 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.1.normal.js @@ -1,7 +1,14 @@ //// [awaitUsingDeclarations.15.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; async function f() { - await using _ = { - async [Symbol.asyncDispose] () {} + try { + var _usingCtx = _using_ctx(); + const _ = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); } - ; } diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.2.minified.js index a80aa01962fa..9ef0acd65b91 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.2.minified.js @@ -1 +1,2 @@ //// [awaitUsingDeclarations.15.ts] +import "@swc/helpers/_/_using_ctx"; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).1.normal.js index 5089cb17fb99..5e64ce262f0e 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).1.normal.js @@ -1,9 +1,16 @@ //// [awaitUsingDeclarations.2.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - await using d1 = { - async [Symbol.asyncDispose] () {} - }, d2 = { - async [Symbol.asyncDispose] () {} + try { + var _usingCtx = _using_ctx(); + const d1 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }), d2 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); } - ; }export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).2.minified.js index 4e2501bb89da..b0930ba472dd 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).2.minified.js @@ -1,7 +1,14 @@ //// [awaitUsingDeclarations.2.ts] -await using d1 = { - async [Symbol.asyncDispose] () {} -}, d2 = { - async [Symbol.asyncDispose] () {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }), _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); } -export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).1.normal.js index bbc02b6cbfd1..645f4b1c1805 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).1.normal.js @@ -1,9 +1,16 @@ //// [awaitUsingDeclarations.3.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - await using d1 = { - async [Symbol.asyncDispose] () {} - }, d2 = null, d3 = undefined, d4 = { - [Symbol.dispose] () {} + try { + var _usingCtx = _using_ctx(); + const d1 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }), d2 = _usingCtx.a(null), d3 = _usingCtx.a(undefined), d4 = _usingCtx.a({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); } - ; }export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).2.minified.js index 375a99335715..f2f521bcbbcd 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).2.minified.js @@ -1,7 +1,14 @@ //// [awaitUsingDeclarations.3.ts] -await using d1 = { - async [Symbol.asyncDispose] () {} -}, d2 = null, d3 = void 0, d4 = { - [Symbol.dispose] () {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }), _usingCtx.a(null), _usingCtx.a(void 0), _usingCtx.a({ + [Symbol.dispose] () {} + }); +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); } -export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.1.normal.js index e007d7ded823..e3f89b0810d8 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.1.normal.js @@ -1,5 +1,12 @@ //// [awaitUsingDeclarations.9.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - await using a = null - ; + try { + var _usingCtx = _using_ctx(); + const a = _usingCtx.a(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + await _usingCtx.d(); + } }export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.2.minified.js index 15415176f800..10b581c62b46 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.2.minified.js @@ -1,3 +1,10 @@ //// [awaitUsingDeclarations.9.ts] -await using a = null -export { }; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.a(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).1.normal.js index 486397d3a71b..51c6a9728631 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).1.normal.js @@ -1,6 +1,7 @@ //// [awaitUsingDeclarationsInForAwaitOf.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; async function main() { - for await (await using d1 of [ + for await (const d1 of [ { async [Symbol.asyncDispose] () {} }, @@ -9,5 +10,14 @@ async function main() { }, null, undefined - ]){} + ]){ + try { + var _usingCtx = _using_ctx(); + {} + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + } } diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).2.minified.js index c966aa67d5da..35eb661ced31 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).2.minified.js @@ -1 +1,2 @@ //// [awaitUsingDeclarationsInForAwaitOf.ts] +import "@swc/helpers/_/_using_ctx"; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).1.normal.js index 3af7fa2c6335..b539d27f7acb 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).1.normal.js @@ -1,6 +1,7 @@ //// [awaitUsingDeclarationsInForOf.1.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; async function main() { - for (await using d1 of [ + for (const d1 of [ { async [Symbol.asyncDispose] () {} }, @@ -9,5 +10,14 @@ async function main() { }, null, undefined - ]){} + ]){ + try { + var _usingCtx = _using_ctx(); + {} + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + } } diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).2.minified.js index 595b77faf6b9..7cfe7407750d 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).2.minified.js @@ -1 +1,2 @@ //// [awaitUsingDeclarationsInForOf.1.ts] +import "@swc/helpers/_/_using_ctx"; diff --git a/crates/swc/tests/tsc-references/callChainWithSuper(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/callChainWithSuper(target=esnext).1.normal.js new file mode 100644 index 000000000000..ce601df18e60 --- /dev/null +++ b/crates/swc/tests/tsc-references/callChainWithSuper(target=esnext).1.normal.js @@ -0,0 +1,13 @@ +//// [callChainWithSuper.ts] +// GH#34952 +class Base { + method() {} +} +class Derived extends Base { + method1() { + return super.method?.(); + } + method2() { + return super["method"]?.(); + } +} diff --git a/crates/swc/tests/tsc-references/callChainWithSuper(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/callChainWithSuper(target=esnext).2.minified.js new file mode 100644 index 000000000000..030074d45cfb --- /dev/null +++ b/crates/swc/tests/tsc-references/callChainWithSuper(target=esnext).2.minified.js @@ -0,0 +1 @@ +//// [callChainWithSuper.ts] diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod14.1.normal.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod14.1.normal.js index 69e7a88484c8..fd5061b60e2c 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod14.1.normal.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod14.1.normal.js @@ -1,6 +1,7 @@ //// [decoratorOnClassMethod14.ts] +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; class Foo { - @decorator foo() { return 0; } @@ -10,3 +11,9 @@ class Foo { }; } } +_ts_decorate([ + decorator, + _ts_metadata("design:type", Function), + _ts_metadata("design:paramtypes", []), + _ts_metadata("design:returntype", void 0) +], Foo.prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod14.2.minified.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod14.2.minified.js index 7fa87d1c98ec..122781d6ac11 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod14.2.minified.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod14.2.minified.js @@ -1 +1,16 @@ //// [decoratorOnClassMethod14.ts] +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; +_ts_decorate([ + decorator, + _ts_metadata("design:type", Function), + _ts_metadata("design:paramtypes", []), + _ts_metadata("design:returntype", void 0) +], (class { + foo() { + return 0; + } + constructor(){ + this.prop = ()=>0; + } +}).prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod15.1.normal.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod15.1.normal.js index d752697a2294..3469288fbbf8 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod15.1.normal.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod15.1.normal.js @@ -1,6 +1,7 @@ //// [decoratorOnClassMethod15.ts] +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; class Foo { - @decorator foo() { return 0; } @@ -8,3 +9,9 @@ class Foo { this.prop = 1; } } +_ts_decorate([ + decorator, + _ts_metadata("design:type", Function), + _ts_metadata("design:paramtypes", []), + _ts_metadata("design:returntype", void 0) +], Foo.prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod15.2.minified.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod15.2.minified.js index 4277bfb19229..119f32ae4a02 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod15.2.minified.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod15.2.minified.js @@ -1 +1,16 @@ //// [decoratorOnClassMethod15.ts] +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; +_ts_decorate([ + decorator, + _ts_metadata("design:type", Function), + _ts_metadata("design:paramtypes", []), + _ts_metadata("design:returntype", void 0) +], (class { + foo() { + return 0; + } + constructor(){ + this.prop = 1; + } +}).prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod16.1.normal.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod16.1.normal.js index 672c5d7989d8..57c1fd676811 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod16.1.normal.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod16.1.normal.js @@ -1,7 +1,14 @@ //// [decoratorOnClassMethod16.ts] +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; class Foo { - @decorator foo() { return 0; } } +_ts_decorate([ + decorator, + _ts_metadata("design:type", Function), + _ts_metadata("design:paramtypes", []), + _ts_metadata("design:returntype", void 0) +], Foo.prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod16.2.minified.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod16.2.minified.js index ed100fcc0dfc..6825f2a25134 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod16.2.minified.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod16.2.minified.js @@ -1 +1,13 @@ //// [decoratorOnClassMethod16.ts] +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; +_ts_decorate([ + decorator, + _ts_metadata("design:type", Function), + _ts_metadata("design:paramtypes", []), + _ts_metadata("design:returntype", void 0) +], (class { + foo() { + return 0; + } +}).prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod18.1.normal.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod18.1.normal.js index 52505360e685..5dafbd9caa37 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod18.1.normal.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod18.1.normal.js @@ -1,3 +1,7 @@ //// [decoratorOnClassMethod18.ts] +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; class Foo { } +_ts_decorate([ + decorator() +], Foo.prototype, "p2", void 0); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod18.2.minified.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod18.2.minified.js index 50e405e02fed..448fb14ee2d3 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod18.2.minified.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod18.2.minified.js @@ -1 +1,6 @@ //// [decoratorOnClassMethod18.ts] +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +_ts_decorate([ + decorator() +], (class { +}).prototype, "p2", void 0); diff --git a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).1.normal.js index 848ac78dcdc3..73c4480e1d09 100644 --- a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).1.normal.js @@ -1,5 +1,5 @@ //// [typeOfThisInStaticMembers10.ts] -@foo +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; class C { static{ this.a = 1; @@ -8,7 +8,9 @@ class C { this.b = this.a + 1; } } -@foo +C = _ts_decorate([ + foo +], C); class D extends C { static{ this.c = 2; @@ -37,6 +39,9 @@ class D extends C { this.c = v + 1; } } +D = _ts_decorate([ + foo +], D); class CC { static{ this.a = 1; diff --git a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).2.minified.js index 5753d39849c7..704545d184f2 100644 --- a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).2.minified.js @@ -1,5 +1,5 @@ //// [typeOfThisInStaticMembers10.ts] -@foo +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; class C { static{ this.a = 1; @@ -8,7 +8,9 @@ class C { this.b = this.a + 1; } } -@foo +C = _ts_decorate([ + foo +], C); class D extends C { static{ this.c = 2; @@ -37,6 +39,9 @@ class D extends C { this.c = v + 1; } } +D = _ts_decorate([ + foo +], D); class CC { static{ this.a = 1; diff --git a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).1.normal.js index 57e76e3e494d..814b7b99ddd2 100644 --- a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).1.normal.js @@ -1,10 +1,12 @@ //// [typeOfThisInStaticMembers11.ts] -@foo +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; class C { static a = 1; static b = this.a + 1; } -@foo +C = _ts_decorate([ + foo +], C); class D extends C { static c = 2; static d = this.c + 1; @@ -23,6 +25,9 @@ class D extends C { this.c = v + 1; } } +D = _ts_decorate([ + foo +], D); class CC { static a = 1; static b = this.a + 1; diff --git a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).2.minified.js index 320901b62061..744520a09fa5 100644 --- a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).2.minified.js @@ -1,10 +1,12 @@ //// [typeOfThisInStaticMembers11.ts] -@foo +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; class C { static a = 1; static b = this.a + 1; } -@foo +C = _ts_decorate([ + foo +], C); class D extends C { static c = 2; static d = this.c + 1; @@ -23,6 +25,9 @@ class D extends C { this.c = v + 1; } } +D = _ts_decorate([ + foo +], D); class CC { static a = 1; static b = this.a + 1; diff --git a/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).1.normal.js index 0b0922dd5827..c60cf682c836 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).1.normal.js @@ -1,211 +1,407 @@ //// [usingDeclarations.1.ts] -using d1 = { - [Symbol.dispose] () {} -} -function f() { - using d2 = { - [Symbol.dispose] () {} - } - ; -} -async function af() { - using d3 = { +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + var d1 = _usingCtx.u({ [Symbol.dispose] () {} + }); + function f() { + try { + var _usingCtx = _using_ctx(); + const d2 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - await null; -} -function* g() { - using d4 = { - [Symbol.dispose] () {} + async function af() { + try { + var _usingCtx = _using_ctx(); + const d3 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + await null; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - yield; -} -async function* ag() { - using d5 = { - [Symbol.dispose] () {} + function* g() { + try { + var _usingCtx = _using_ctx(); + const d4 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + yield; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - yield; - await null; -} -const a = ()=>{ - using d6 = { - [Symbol.dispose] () {} + async function* ag() { + try { + var _usingCtx = _using_ctx(); + const d5 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + yield; + await null; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; -}; -class C1 { - constructor(){ - this.a = ()=>{ - using d7 = { + const a = ()=>{ + try { + var _usingCtx = _using_ctx(); + const d6 = _usingCtx.u({ [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + }; + class C1 { + constructor(){ + this.a = ()=>{ + try { + var _usingCtx = _using_ctx(); + const d7 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + }; + try { + var _usingCtx = _using_ctx(); + const d8 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); } - ; - }; - using d8 = { - [Symbol.dispose] () {} } - ; - } - static{ - using d9 = { - [Symbol.dispose] () {} + static{ + try { + var _usingCtx = _using_ctx(); + const d9 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - } - m() { - using d10 = { - [Symbol.dispose] () {} + m() { + try { + var _usingCtx = _using_ctx(); + const d10 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - } - get x() { - using d11 = { - [Symbol.dispose] () {} + get x() { + try { + var _usingCtx = _using_ctx(); + const d11 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + return 0; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - return 0; - } - set x(v) { - using d12 = { - [Symbol.dispose] () {} + set x(v) { + try { + var _usingCtx = _using_ctx(); + const d12 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - } - async am() { - using d13 = { - [Symbol.dispose] () {} + async am() { + try { + var _usingCtx = _using_ctx(); + const d13 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + await null; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - await null; - } - *g() { - using d14 = { - [Symbol.dispose] () {} + *g() { + try { + var _usingCtx = _using_ctx(); + const d14 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + yield; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + } + async *ag() { + try { + var _usingCtx = _using_ctx(); + const d15 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + yield; + await null; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - yield; } - async *ag() { - using d15 = { - [Symbol.dispose] () {} + class C2 extends C1 { + constructor(){ + try { + var _usingCtx = _using_ctx(); + const d16 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + super(); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - yield; - await null; } -} -class C2 extends C1 { - constructor(){ - using d16 = { - [Symbol.dispose] () {} + class C3 extends C1 { + constructor(){ + try { + var _usingCtx = _using_ctx(); + const d17 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + super(), this.y = 1; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - ; - super(); } -} -class C3 extends C1 { - constructor(){ - using d17 = { - [Symbol.dispose] () {} + (function(N) { + try { + var _usingCtx = _using_ctx(); + var d18 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + })(N || (N = {})); + { + try { + var _usingCtx1 = _using_ctx(); + const d19 = _usingCtx1.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx1.e = _; + } finally{ + _usingCtx1.d(); } - ; - super(), this.y = 1; } -} -(function(N) { - using d18 = { - [Symbol.dispose] () {} + switch(Math.random()){ + case 0: + try { + var _usingCtx2 = _using_ctx(); + const d20 = _usingCtx2.u({ + [Symbol.dispose] () {} + }); + break; + } catch (_) { + _usingCtx2.e = _; + } finally{ + _usingCtx2.d(); + } + case 1: + try { + var _usingCtx3 = _using_ctx(); + const d21 = _usingCtx3.u({ + [Symbol.dispose] () {} + }); + break; + } catch (_) { + _usingCtx3.e = _; + } finally{ + _usingCtx3.d(); + } } -})(N || (N = {})); -{ - using d19 = { - [Symbol.dispose] () {} + if (true) switch(0){ + case 0: + try { + var _usingCtx4 = _using_ctx(); + const d22 = _usingCtx4.u({ + [Symbol.dispose] () {} + }); + break; + } catch (_) { + _usingCtx4.e = _; + } finally{ + _usingCtx4.d(); + } } - ; -}switch(Math.random()){ - case 0: - using d20 = { - [Symbol.dispose] () {} + try { + try { + var _usingCtx5 = _using_ctx(); + const d23 = _usingCtx5.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx5.e = _; + } finally{ + _usingCtx5.d(); } - ; - break; - case 1: - using d21 = { - [Symbol.dispose] () {} + } catch { + try { + var _usingCtx6 = _using_ctx(); + const d24 = _usingCtx6.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx6.e = _; + } finally{ + _usingCtx6.d(); } - ; - break; -} -if (true) switch(0){ - case 0: - using d22 = { - [Symbol.dispose] () {} + } finally{ + try { + var _usingCtx7 = _using_ctx(); + const d25 = _usingCtx7.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx7.e = _; + } finally{ + _usingCtx7.d(); } - ; - break; -} -try { - using d23 = { - [Symbol.dispose] () {} - } - ; -} catch { - using d24 = { - [Symbol.dispose] () {} - } - ; -} finally{ - using d25 = { - [Symbol.dispose] () {} } - ; -} -if (true) { - using d26 = { - [Symbol.dispose] () {} - } - ; -} else { - using d27 = { - [Symbol.dispose] () {} - } - ; -} -while(true){ - using d28 = { - [Symbol.dispose] () {} + if (true) { + try { + var _usingCtx8 = _using_ctx(); + const d26 = _usingCtx8.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx8.e = _; + } finally{ + _usingCtx8.d(); + } + } else { + try { + var _usingCtx9 = _using_ctx(); + const d27 = _usingCtx9.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx9.e = _; + } finally{ + _usingCtx9.d(); + } } - ; - break; -} -do { - using d29 = { - [Symbol.dispose] () {} + while(true){ + try { + var _usingCtx10 = _using_ctx(); + const d28 = _usingCtx10.u({ + [Symbol.dispose] () {} + }); + break; + } catch (_) { + _usingCtx10.e = _; + } finally{ + _usingCtx10.d(); + } } - ; - break; -}while (true) -for(;;){ - using d30 = { - [Symbol.dispose] () {} + do { + try { + var _usingCtx11 = _using_ctx(); + const d29 = _usingCtx11.u({ + [Symbol.dispose] () {} + }); + break; + } catch (_) { + _usingCtx11.e = _; + } finally{ + _usingCtx11.d(); + } + }while (true) + for(;;){ + try { + var _usingCtx12 = _using_ctx(); + const d30 = _usingCtx12.u({ + [Symbol.dispose] () {} + }); + break; + } catch (_) { + _usingCtx12.e = _; + } finally{ + _usingCtx12.d(); + } } - ; - break; -} -for(const x in {}){ - using d31 = { - [Symbol.dispose] () {} + for(const x in {}){ + try { + var _usingCtx13 = _using_ctx(); + const d31 = _usingCtx13.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx13.e = _; + } finally{ + _usingCtx13.d(); + } } - ; -} -for (const x of []){ - using d32 = { - [Symbol.dispose] () {} + for (const x of []){ + try { + var _usingCtx14 = _using_ctx(); + const d32 = _usingCtx14.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx14.e = _; + } finally{ + _usingCtx14.d(); + } } - ; + var N; +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -var N; export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).2.minified.js index 5d79f0847483..c757c3f676a5 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).2.minified.js @@ -1,119 +1,276 @@ //// [usingDeclarations.1.ts] -var N; -using d1 = { - [Symbol.dispose] () {} -} -class C1 { - constructor(){ - this.a = ()=>{ - using d7 = { - [Symbol.dispose] () {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var N, _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }); + class C1 { + constructor(){ + this.a = ()=>{ + try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + }; + try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); } - }; - using d8 = { - [Symbol.dispose] () {} } - } - static{ - using d9 = { - [Symbol.dispose] () {} + static{ + try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - } - m() { - using d10 = { - [Symbol.dispose] () {} + m() { + try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - } - get x() { - using d11 = { - [Symbol.dispose] () {} + get x() { + try { + var _usingCtx = _using_ctx(); + return _usingCtx.u({ + [Symbol.dispose] () {} + }), 0; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + } + set x(v) { + try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + } + async am() { + try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }), await null; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + } + *g() { + try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }), yield; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + } + async *ag() { + try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }), yield, await null; + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } - return 0; } - set x(v) { - using d12 = { - [Symbol.dispose] () {} + !function(N) { + try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); } + }(N || (N = {})); + try { + var _usingCtx1 = _using_ctx(); + _usingCtx1.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx1.e = _; + } finally{ + _usingCtx1.d(); } - async am() { - using d13 = { + switch(Math.random()){ + case 0: + try { + var _usingCtx2 = _using_ctx(); + _usingCtx2.u({ + [Symbol.dispose] () {} + }); + break; + } catch (_) { + _usingCtx2.e = _; + } finally{ + _usingCtx2.d(); + } + case 1: + try { + var _usingCtx3 = _using_ctx(); + _usingCtx3.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx3.e = _; + } finally{ + _usingCtx3.d(); + } + } + try { + var _usingCtx4 = _using_ctx(); + _usingCtx4.u({ [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx4.e = _; + } finally{ + _usingCtx4.d(); + } + try { + try { + var _usingCtx5 = _using_ctx(); + _usingCtx5.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx5.e = _; + } finally{ + _usingCtx5.d(); + } + } catch { + try { + var _usingCtx6 = _using_ctx(); + _usingCtx6.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx6.e = _; + } finally{ + _usingCtx6.d(); + } + } finally{ + try { + var _usingCtx7 = _using_ctx(); + _usingCtx7.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx7.e = _; + } finally{ + _usingCtx7.d(); } - await null; } - *g() { - using d14 = { + try { + var _usingCtx8 = _using_ctx(); + _usingCtx8.u({ [Symbol.dispose] () {} - } - yield; + }); + } catch (_) { + _usingCtx8.e = _; + } finally{ + _usingCtx8.d(); } - async *ag() { - using d15 = { + for(;;)try { + var _usingCtx10 = _using_ctx(); + _usingCtx10.u({ [Symbol.dispose] () {} - } - yield, await null; + }); + break; + } catch (_) { + _usingCtx10.e = _; + } finally{ + _usingCtx10.d(); } -} -!function(N) { - using d18 = { - [Symbol.dispose] () {} + for(;;)try { + var _usingCtx11 = _using_ctx(); + _usingCtx11.u({ + [Symbol.dispose] () {} + }); + break; + } catch (_) { + _usingCtx11.e = _; + } finally{ + _usingCtx11.d(); } -}(N || (N = {})); -using d19 = { - [Symbol.dispose] () {} -} -switch(Math.random()){ - case 0: - using d20 = { + for(;;)try { + var _usingCtx12 = _using_ctx(); + _usingCtx12.u({ [Symbol.dispose] () {} - } + }); break; - case 1: - using d21 = { + } catch (_) { + _usingCtx12.e = _; + } finally{ + _usingCtx12.d(); + } + for(let x in {})try { + var _usingCtx13 = _using_ctx(); + _usingCtx13.u({ [Symbol.dispose] () {} - } -} -using d22 = { - [Symbol.dispose] () {} -} -try { - using d23 = { - [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx13.e = _; + } finally{ + _usingCtx13.d(); } -} catch { - using d24 = { - [Symbol.dispose] () {} + for (let x of [])try { + var _usingCtx14 = _using_ctx(); + _usingCtx14.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx14.e = _; + } finally{ + _usingCtx14.d(); } +} catch (_) { + _usingCtx.e = _; } finally{ - using d25 = { - [Symbol.dispose] () {} - } -} -using d26 = { - [Symbol.dispose] () {} -} -for(;;){ - using d28 = { - [Symbol.dispose] () {} - } - break; -} -for(;;){ - using d29 = { - [Symbol.dispose] () {} - } - break; -} -for(;;){ - using d30 = { - [Symbol.dispose] () {} - } - break; -} -for(let x in {})using d31 = { - [Symbol.dispose] () {} -} -for (let x of [])using d32 = { - [Symbol.dispose] () {} + _usingCtx.d(); } -export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarations.14.1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.14.1.normal.js index f5feea9b25c3..cfbfba2ad869 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.14.1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.14.1.normal.js @@ -1,2 +1,10 @@ //// [usingDeclarations.14.ts] -using x = {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + var x = _usingCtx.u({}); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarations.14.2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.14.2.minified.js index f5feea9b25c3..e50f2dc1dea4 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.14.2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.14.2.minified.js @@ -1,2 +1,10 @@ //// [usingDeclarations.14.ts] -using x = {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u({}); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarations.15.1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.15.1.normal.js index f51b8f73778c..bea8776ea040 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.15.1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.15.1.normal.js @@ -1,5 +1,13 @@ //// [usingDeclarations.15.ts] -using _ = { - [Symbol.dispose] () {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + var _ = _usingCtx.u({ + [Symbol.dispose] () {} + }); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarations.15.2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.15.2.minified.js index f51b8f73778c..a1f9133d0799 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.15.2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.15.2.minified.js @@ -1,5 +1,12 @@ //// [usingDeclarations.15.ts] -using _ = { - [Symbol.dispose] () {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).1.normal.js index 6d1c7712f296..ebd9d72663f3 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).1.normal.js @@ -1,9 +1,16 @@ //// [usingDeclarations.2.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - using d1 = { - [Symbol.dispose] () {} - }, d2 = { - [Symbol.dispose] () {} + try { + var _usingCtx = _using_ctx(); + const d1 = _usingCtx.u({ + [Symbol.dispose] () {} + }), d2 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); } - ; } diff --git a/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).2.minified.js index 3671aefc108a..45ef9b4d6f41 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).2.minified.js @@ -1,6 +1,14 @@ //// [usingDeclarations.2.ts] -using d1 = { - [Symbol.dispose] () {} -}, d2 = { - [Symbol.dispose] () {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }), _usingCtx.u({ + [Symbol.dispose] () {} + }); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).1.normal.js index 4043e7154267..6f27d83c73a8 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).1.normal.js @@ -1,9 +1,16 @@ //// [usingDeclarations.3.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - using d1 = { - [Symbol.dispose] () {} - }, d2 = null, d3 = undefined, d4 = { - [Symbol.dispose] () {} + try { + var _usingCtx = _using_ctx(); + const d1 = _usingCtx.u({ + [Symbol.dispose] () {} + }), d2 = _usingCtx.u(null), d3 = _usingCtx.u(undefined), d4 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); } - ; } diff --git a/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).2.minified.js index 9cf93e3b8ba0..d9daab6fa430 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).2.minified.js @@ -1,6 +1,14 @@ //// [usingDeclarations.3.ts] -using d1 = { - [Symbol.dispose] () {} -}, d2 = null, d3 = void 0, d4 = { - [Symbol.dispose] () {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }), _usingCtx.u(null), _usingCtx.u(void 0), _usingCtx.u({ + [Symbol.dispose] () {} + }); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarations.9.1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.9.1.normal.js index 3a2079d76250..970efa4e9e24 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.9.1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.9.1.normal.js @@ -1,5 +1,12 @@ //// [usingDeclarations.9.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - using a = null - ; + try { + var _usingCtx = _using_ctx(); + const a = _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } diff --git a/crates/swc/tests/tsc-references/usingDeclarations.9.2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.9.2.minified.js index 8896bff0f17d..838a1525bee2 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.9.2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.9.2.minified.js @@ -1,2 +1,10 @@ //// [usingDeclarations.9.ts] -using a = null +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.1.normal.js index 64f638f25e34..fb0905592aa1 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.1.normal.js @@ -1,9 +1,17 @@ //// [usingDeclarationsDeclarationEmit.1.ts] -using r1 = { - [Symbol.dispose] () {} -} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; export { r1 }; -await using r2 = { - async [Symbol.asyncDispose] () {} -} export { r2 }; +try { + var _usingCtx = _using_ctx(); + var r1 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + var r2 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.2.minified.js index 093c8aed77fd..4222545f0b31 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.2.minified.js @@ -1,8 +1,14 @@ //// [usingDeclarationsDeclarationEmit.1.ts] -using r1 = { - [Symbol.dispose] () {} -} -await using r2 = { - async [Symbol.asyncDispose] () {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(), r1 = _usingCtx.u({ + [Symbol.dispose] () {} + }), r2 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); } export { r1, r2 }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.1.normal.js index fe3fccbcf40a..5c38eddf239d 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.1.normal.js @@ -1,8 +1,16 @@ //// [usingDeclarationsDeclarationEmit.2.ts] -using r1 = { - [Symbol.dispose] () {} -} -await using r2 = { - async [Symbol.asyncDispose] () {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + var r1 = _usingCtx.u({ + [Symbol.dispose] () {} + }); + var r2 = _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); } export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.2.minified.js index fe3fccbcf40a..58dec52a1ed4 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.2.minified.js @@ -1,8 +1,14 @@ //// [usingDeclarationsDeclarationEmit.2.ts] -using r1 = { - [Symbol.dispose] () {} +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u({ + [Symbol.dispose] () {} + }), _usingCtx.a({ + async [Symbol.asyncDispose] () {} + }); +} catch (_) { + _usingCtx.e = _; +} finally{ + await _usingCtx.d(); } -await using r2 = { - async [Symbol.asyncDispose] () {} -} -export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).1.normal.js index 087377eccea6..c7af45306326 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).1.normal.js @@ -1,10 +1,20 @@ //// [usingDeclarationsInForAwaitOf.ts] +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; async function main() { - for await (using d1 of [ + for await (const d1 of [ { [Symbol.dispose] () {} }, null, undefined - ]){} + ]){ + try { + var _usingCtx = _using_ctx(); + {} + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } + } } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).2.minified.js index f8d980c11c08..d4aece823eb8 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).2.minified.js @@ -1 +1,2 @@ //// [usingDeclarationsInForAwaitOf.ts] +import "@swc/helpers/_/_using_ctx"; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).1.normal.js index e6deb8d99972..800b83760a49 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).1.normal.js @@ -1,8 +1,18 @@ //// [usingDeclarationsInForOf.1.ts] -for (using d1 of [ +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +for (const d1 of [ { [Symbol.dispose] () {} }, null, undefined -]){} +]){ + try { + var _usingCtx = _using_ctx(); + {} + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).2.minified.js index 7d5eedb7dc8f..834d99aa8f7b 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).2.minified.js @@ -1,8 +1,15 @@ //// [usingDeclarationsInForOf.1.ts] -for (using d1 of [ +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +for (let d1 of [ { [Symbol.dispose] () {} }, null, void 0 -]); +])try { + var _usingCtx = _using_ctx(); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).1.normal.js index 165d29c37ea4..b29dc452d1fe 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).1.normal.js @@ -3,7 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true }); -using before = null -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + var before = _usingCtx.u(null); + class C { + } + C = _ts_decorate._([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).2.minified.js index 87827813aa9b..c4a2f9568a0f 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).2.minified.js @@ -2,4 +2,17 @@ Object.defineProperty(exports, "__esModule", { value: !0 }); -using before = null +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + _usingCtx.u(null); + class C { + } + C = _ts_decorate._([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).1.normal.js index d2dbe1ae7608..036b36e82eb7 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).1.normal.js @@ -1,6 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.1.ts] -using before = null -@dec -class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + class C { + } + C = _ts_decorate([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).2.minified.js index 11a587afae4a..89afdaf62485 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).2.minified.js @@ -1,3 +1,16 @@ //// [usingDeclarationsWithLegacyClassDecorators.1.ts] -using before = null -export { }; +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + class C { + } + C = _ts_decorate([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).1.normal.js index 9806e3db0199..bf6171222432 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).1.normal.js @@ -1,14 +1,33 @@ //// [usingDeclarationsWithLegacyClassDecorators.1.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - var C; + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null - C = @dec - class C { - }; + try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + class C { + } + C = _ts_decorate([ + dec + ], C); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).2.minified.js index 5860636c58ab..eb06e75805f5 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).2.minified.js @@ -1,9 +1,32 @@ //// [usingDeclarationsWithLegacyClassDecorators.1.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null + try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + class C { + } + C = _ts_decorate([ + dec + ], C); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).1.normal.js index 6c62feb5287a..abdfcde66ed6 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).1.normal.js @@ -6,10 +6,21 @@ Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "default", { enumerable: true, get: function() { - return _default; + return _class; } }); -@dec -class _default { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + var _class = class _class { + }; + _class = _ts_decorate._([ + dec + ], _class); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).2.minified.js index e6c8b99eb38e..025220975440 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).2.minified.js @@ -4,10 +4,18 @@ Object.defineProperty(exports, "__esModule", { }), Object.defineProperty(exports, "default", { enumerable: !0, get: function() { - return _default; + return _class; } }); -@dec -class _default { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(), _class = class { + }; + _class = _ts_decorate._([ + dec + ], _class), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).1.normal.js index ecf1ec216856..ffed1694dcb1 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).1.normal.js @@ -1,5 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.10.ts] -export default @dec -class { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +export { _class as default }; +try { + var _usingCtx = _using_ctx(); + var _class = class _class { + }; + _class = _ts_decorate([ + dec + ], _class); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).2.minified.js index ecf1ec216856..8b1e6147911a 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).2.minified.js @@ -1,5 +1,15 @@ //// [usingDeclarationsWithLegacyClassDecorators.10.ts] -export default @dec -class { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(), _class = class { + }; + _class = _ts_decorate([ + dec + ], _class), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null +export { _class as default }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).1.normal.js index 87a21074b5df..881ecb69908c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).1.normal.js @@ -1,13 +1,33 @@ //// [usingDeclarationsWithLegacyClassDecorators.10.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - _export("default", @dec - class { - }); + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using after = null + try { + var _usingCtx = _using_ctx(); + var _class = class _class { + }; + _export("default", _class = _ts_decorate([ + dec + ], _class)); + var after = _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).2.minified.js index f6db4491104c..118dd094ae31 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).2.minified.js @@ -1,11 +1,30 @@ //// [usingDeclarationsWithLegacyClassDecorators.10.ts] -System.register([], function(_export, _context) { - return _export("default", @dec - class { - }), { - setters: [], +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; + return { + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using after = null + try { + var _usingCtx = _using_ctx(), _class = class { + }; + _export("default", _class = _ts_decorate([ + dec + ], _class)), _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).1.normal.js index 1edd1acf28fe..5cbd98dbc701 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).1.normal.js @@ -9,7 +9,18 @@ Object.defineProperty(exports, "C", { return C; } }); -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + class C { + } + C = _ts_decorate._([ + dec + ], C); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).2.minified.js index d966acbb5f0e..892d8ceeb02b 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).2.minified.js @@ -7,7 +7,16 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + class C1 { + } + C1 = _ts_decorate._([ + dec + ], C1), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).1.normal.js index 8705007ccb8f..2daa7fe9636f 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).1.normal.js @@ -1,6 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.11.ts] -@dec -class C { -} +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; export { C }; -using after = null +try { + var _usingCtx = _using_ctx(); + class C { + } + C = _ts_decorate([ + dec + ], C); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).2.minified.js index 0356f412e6f1..74007d040bac 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).2.minified.js @@ -1,6 +1,16 @@ //// [usingDeclarationsWithLegacyClassDecorators.11.ts] -@dec -class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + class C { + } + C = _ts_decorate([ + dec + ], C), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null export { C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).1.normal.js index f0ccad931f6c..7d98f05d9d82 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).1.normal.js @@ -1,14 +1,33 @@ //// [usingDeclarationsWithLegacyClassDecorators.11.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - var C; + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - _export("C", C = @dec - class C { - }); - using after = null + try { + var _usingCtx = _using_ctx(); + class C { + } + _export("C", C = _ts_decorate([ + dec + ], C)); + var after = _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).2.minified.js index 8ddf4fcfcafb..1f6e0fa7f09c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).2.minified.js @@ -1,12 +1,31 @@ //// [usingDeclarationsWithLegacyClassDecorators.11.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - _export("C", @dec - class { - }); - using after = null + try { + var _usingCtx = _using_ctx(); + class C { + } + _export("C", C = _ts_decorate([ + dec + ], C)), _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).1.normal.js index df42af76969f..eaef720a233d 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).1.normal.js @@ -9,7 +9,18 @@ Object.defineProperty(exports, "D", { return C; } }); -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + class C { + } + C = _ts_decorate._([ + dec + ], C); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).2.minified.js index 28aec2731e69..e9dd78c1b36d 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).2.minified.js @@ -7,7 +7,16 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + class C1 { + } + C1 = _ts_decorate._([ + dec + ], C1), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).1.normal.js index 5730b47c51e2..a21418310128 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).1.normal.js @@ -1,6 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.12.ts] -@dec -class C { -} +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; export { C as D }; -using after = null +try { + var _usingCtx = _using_ctx(); + class C { + } + C = _ts_decorate([ + dec + ], C); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).2.minified.js index 6c76452cfa64..96a12738b3e3 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).2.minified.js @@ -1,6 +1,16 @@ //// [usingDeclarationsWithLegacyClassDecorators.12.ts] -@dec -class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + class C { + } + C = _ts_decorate([ + dec + ], C), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null export { C as D }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).1.normal.js index c1c9143b3030..8aae998a8767 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).1.normal.js @@ -1,14 +1,33 @@ //// [usingDeclarationsWithLegacyClassDecorators.12.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - var C; + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - _export("D", C = @dec - class C { - }); - using after = null + try { + var _usingCtx = _using_ctx(); + class C { + } + _export("D", C = _ts_decorate([ + dec + ], C)); + var after = _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).2.minified.js index 84172012e65b..0d8a2fe98456 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).2.minified.js @@ -1,12 +1,31 @@ //// [usingDeclarationsWithLegacyClassDecorators.12.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - _export("D", @dec - class { - }); - using after = null + try { + var _usingCtx = _using_ctx(); + class C { + } + _export("D", C = _ts_decorate([ + dec + ], C)), _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).1.normal.js index 81b834ce4206..0deba7a50d7f 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).1.normal.js @@ -6,10 +6,23 @@ Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "C", { enumerable: true, get: function() { - return C; + return _C; } }); -using before = null -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +var _C; +try { + var _usingCtx = _using_ctx._(); + var before = _usingCtx.u(null); + class C { + } + _C = C; + C = _ts_decorate._([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).2.minified.js index 39ae36b1431c..f3849d640a99 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).2.minified.js @@ -4,10 +4,20 @@ Object.defineProperty(exports, "__esModule", { }), Object.defineProperty(exports, "C", { enumerable: !0, get: function() { - return C; + return _C; } }); -using before = null -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _C, _usingCtx = _using_ctx._(); + _usingCtx.u(null); + class C { + } + _C = C, C = _ts_decorate._([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).1.normal.js index fc2b90b581c0..27865d30b109 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).1.normal.js @@ -1,5 +1,19 @@ //// [usingDeclarationsWithLegacyClassDecorators.2.ts] -using before = null -@dec -export class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +var _C; +try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + class C { + } + _C = C; + C = _ts_decorate([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } +export { _C as C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).2.minified.js index fc2b90b581c0..7e5c750c71b3 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).2.minified.js @@ -1,5 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.2.ts] -using before = null -@dec -export class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _C, _usingCtx = _using_ctx(); + _usingCtx.u(null); + class C { + } + _C = C, C = _ts_decorate([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } +export { _C as C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).1.normal.js index 342eee2ce895..98691c8149e1 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).1.normal.js @@ -1,15 +1,35 @@ //// [usingDeclarationsWithLegacyClassDecorators.2.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - var C; + var _ts_decorate, _using_ctx, _C; _export("C", void 0); return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null - _export("C", C = @dec - class C { - }); + try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + class C { + } + _export("C", _C = C); + C = _ts_decorate([ + dec + ], C); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).2.minified.js index 90e57fc5d8ab..f7a8aae41569 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).2.minified.js @@ -1,12 +1,32 @@ //// [usingDeclarationsWithLegacyClassDecorators.2.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; return _export("C", void 0), { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null - _export("C", @dec - class { - }); + try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + class C { + } + _export("C", C), C = _ts_decorate([ + dec + ], C); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).1.normal.js index c5c6fd8468b6..cdfae9e0bf96 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).1.normal.js @@ -9,7 +9,18 @@ Object.defineProperty(exports, "default", { return C; } }); -using before = null -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + var before = _usingCtx.u(null); + var C = class C { + }; + C = _ts_decorate._([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).2.minified.js index 3b5844f85c1a..8a31f307ff05 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).2.minified.js @@ -7,7 +7,17 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -using before = null -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + _usingCtx.u(null); + var C = class { + }; + C = _ts_decorate._([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).1.normal.js index 477d017ae912..06cb6c24d36c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).1.normal.js @@ -1,5 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.3.ts] -using before = null -export default @dec -class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +export { C as default }; +try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + var C = class C { + }; + C = _ts_decorate([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).2.minified.js index 477d017ae912..904b8a4b8e8d 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).2.minified.js @@ -1,5 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.3.ts] -using before = null -export default @dec -class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + var C = class { + }; + C = _ts_decorate([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } +export { C as default }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).1.normal.js index 27e022cc05ec..728117336184 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).1.normal.js @@ -1,15 +1,33 @@ //// [usingDeclarationsWithLegacyClassDecorators.3.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - var C; - _export("default", void 0); + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null - _export("default", C = @dec - class C { - }); + try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + var C = class C { + }; + _export("default", C = _ts_decorate([ + dec + ], C)); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).2.minified.js index 505f03ed65b7..068fe6225f59 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).2.minified.js @@ -1,12 +1,32 @@ //// [usingDeclarationsWithLegacyClassDecorators.3.ts] -System.register([], function(_export, _context) { - return _export("default", void 0), { - setters: [], +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; + return { + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null - _export("default", @dec - class { - }); + try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + var C = class { + }; + _export("default", C = _ts_decorate([ + dec + ], C)); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).1.normal.js index 01e84a330808..40ccb45028ff 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).1.normal.js @@ -6,10 +6,21 @@ Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "default", { enumerable: true, get: function() { - return _default; + return _class; } }); -using before = null -@dec -class _default { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + var before = _usingCtx.u(null); + var _class = class _class { + }; + _class = _ts_decorate._([ + dec + ], _class); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).2.minified.js index 23c421fb14e4..651b4dbc09d5 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).2.minified.js @@ -4,10 +4,20 @@ Object.defineProperty(exports, "__esModule", { }), Object.defineProperty(exports, "default", { enumerable: !0, get: function() { - return _default; + return _class; } }); -using before = null -@dec -class _default { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + _usingCtx.u(null); + var _class = class { + }; + _class = _ts_decorate._([ + dec + ], _class); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).1.normal.js index de9adc6a1e80..494956940d4a 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).1.normal.js @@ -1,5 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.4.ts] -using before = null -export default @dec -class { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +export { _class as default }; +try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + var _class = class _class { + }; + _class = _ts_decorate([ + dec + ], _class); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).2.minified.js index de9adc6a1e80..16fd923fd420 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).2.minified.js @@ -1,5 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.4.ts] -using before = null -export default @dec -class { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + var _class = class { + }; + _class = _ts_decorate([ + dec + ], _class); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } +export { _class as default }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).1.normal.js index 9716a0790f15..d19071f6100c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).1.normal.js @@ -1,13 +1,33 @@ //// [usingDeclarationsWithLegacyClassDecorators.4.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - _export("default", @dec - class { - }); + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null + try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + var _class = class _class { + }; + _export("default", _class = _ts_decorate([ + dec + ], _class)); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).2.minified.js index 11b0d43d5fae..f2954e1f4b1b 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).2.minified.js @@ -1,11 +1,32 @@ //// [usingDeclarationsWithLegacyClassDecorators.4.ts] -System.register([], function(_export, _context) { - return _export("default", @dec - class { - }), { - setters: [], +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; + return { + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null + try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + var _class = class { + }; + _export("default", _class = _ts_decorate([ + dec + ], _class)); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).1.normal.js index 0e134120f21c..3ec36fd8d880 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).1.normal.js @@ -9,7 +9,18 @@ Object.defineProperty(exports, "C", { return C; } }); -using before = null -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + var before = _usingCtx.u(null); + class C { + } + C = _ts_decorate._([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).2.minified.js index 701811d4adda..b6b98e01017c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).2.minified.js @@ -7,7 +7,17 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -using before = null -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + _usingCtx.u(null); + class C1 { + } + C1 = _ts_decorate._([ + dec + ], C1); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).1.normal.js index d3353880c89c..5ca6582ea6a7 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).1.normal.js @@ -1,6 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.5.ts] -using before = null -@dec -class C { -} +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; export { C }; +try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + class C { + } + C = _ts_decorate([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).2.minified.js index d3353880c89c..07486ef3ac46 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).2.minified.js @@ -1,6 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.5.ts] -using before = null -@dec -class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + class C { + } + C = _ts_decorate([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } export { C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).1.normal.js index 2938ae1accf7..3c77cb98fa4e 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).1.normal.js @@ -1,14 +1,33 @@ //// [usingDeclarationsWithLegacyClassDecorators.5.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - var C; + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null - _export("C", C = @dec - class C { - }); + try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + class C { + } + _export("C", C = _ts_decorate([ + dec + ], C)); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).2.minified.js index 07a0d2eb025f..93eeefd42634 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).2.minified.js @@ -1,12 +1,32 @@ //// [usingDeclarationsWithLegacyClassDecorators.5.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null - _export("C", @dec - class { - }); + try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + class C { + } + _export("C", C = _ts_decorate([ + dec + ], C)); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).1.normal.js index 63be7eef33fd..68c7b549b012 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).1.normal.js @@ -9,7 +9,18 @@ Object.defineProperty(exports, "D", { return C; } }); -using before = null -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + var before = _usingCtx.u(null); + class C { + } + C = _ts_decorate._([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).2.minified.js index 845f07857c16..336700d32d3e 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).2.minified.js @@ -7,7 +7,17 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -using before = null -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + _usingCtx.u(null); + class C1 { + } + C1 = _ts_decorate._([ + dec + ], C1); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).1.normal.js index 7e5a8e8ab334..34a460c4368c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).1.normal.js @@ -1,6 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.6.ts] -using before = null -@dec -class C { -} +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; export { C as D }; +try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + class C { + } + C = _ts_decorate([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).2.minified.js index 7e5a8e8ab334..0bcad536860c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).2.minified.js @@ -1,6 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.6.ts] -using before = null -@dec -class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + class C { + } + C = _ts_decorate([ + dec + ], C); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } export { C as D }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).1.normal.js index 2e468a511367..ddf501115f38 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).1.normal.js @@ -1,14 +1,33 @@ //// [usingDeclarationsWithLegacyClassDecorators.6.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - var C; + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null - _export("D", C = @dec - class C { - }); + try { + var _usingCtx = _using_ctx(); + var before = _usingCtx.u(null); + class C { + } + _export("D", C = _ts_decorate([ + dec + ], C)); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).2.minified.js index 2821ed43a920..8ed7bef15037 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).2.minified.js @@ -1,12 +1,32 @@ //// [usingDeclarationsWithLegacyClassDecorators.6.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using before = null - _export("D", @dec - class { - }); + try { + var _usingCtx = _using_ctx(); + _usingCtx.u(null); + class C { + } + _export("D", C = _ts_decorate([ + dec + ], C)); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).1.normal.js index a07e4e1b78d5..9c2698aaab74 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).1.normal.js @@ -3,7 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true }); -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + class C { + } + C = _ts_decorate._([ + dec + ], C); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).2.minified.js index cc7fdd02b2a0..dd66a6ff87ea 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).2.minified.js @@ -2,4 +2,16 @@ Object.defineProperty(exports, "__esModule", { value: !0 }); -using after = null +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + class C { + } + C = _ts_decorate._([ + dec + ], C), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).1.normal.js index c4d480c8af3f..853a3b6b62e6 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).1.normal.js @@ -1,6 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.7.ts] -@dec -class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + class C { + } + C = _ts_decorate([ + dec + ], C); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).2.minified.js index c92fb055da73..86d340d23276 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).2.minified.js @@ -1,3 +1,15 @@ //// [usingDeclarationsWithLegacyClassDecorators.7.ts] -using after = null -export { }; +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(); + class C { + } + C = _ts_decorate([ + dec + ], C), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); +} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).1.normal.js index 9b5a38280397..2e8581f536ce 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).1.normal.js @@ -1,14 +1,33 @@ //// [usingDeclarationsWithLegacyClassDecorators.7.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - var C; + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - C = @dec - class C { - }; - using after = null + try { + var _usingCtx = _using_ctx(); + class C { + } + C = _ts_decorate([ + dec + ], C); + var after = _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).2.minified.js index 55c846507e0d..59a9df2f1e1e 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).2.minified.js @@ -1,9 +1,31 @@ //// [usingDeclarationsWithLegacyClassDecorators.7.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - using after = null + try { + var _usingCtx = _using_ctx(); + class C { + } + C = _ts_decorate([ + dec + ], C), _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).1.normal.js index 859f122834ca..8ae1ece99a0f 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).1.normal.js @@ -6,10 +6,23 @@ Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "C", { enumerable: true, get: function() { - return C; + return _C; } }); -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +var _C; +try { + var _usingCtx = _using_ctx._(); + class C { + } + _C = C; + C = _ts_decorate._([ + dec + ], C); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).2.minified.js index f01dcec32b70..6ba8203d51f1 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).2.minified.js @@ -4,10 +4,19 @@ Object.defineProperty(exports, "__esModule", { }), Object.defineProperty(exports, "C", { enumerable: !0, get: function() { - return C; + return _C; } }); -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _C, _usingCtx = _using_ctx._(); + class C { + } + _C = C, C = _ts_decorate._([ + dec + ], C), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).1.normal.js index b620e670aee8..aa6a7ceef736 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).1.normal.js @@ -1,5 +1,19 @@ //// [usingDeclarationsWithLegacyClassDecorators.8.ts] -@dec -export class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +var _C; +try { + var _usingCtx = _using_ctx(); + class C { + } + _C = C; + C = _ts_decorate([ + dec + ], C); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null +export { _C as C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).2.minified.js index b620e670aee8..10cbe3e0e41f 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).2.minified.js @@ -1,5 +1,16 @@ //// [usingDeclarationsWithLegacyClassDecorators.8.ts] -@dec -export class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _C, _usingCtx = _using_ctx(); + class C { + } + _C = C, C = _ts_decorate([ + dec + ], C), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null +export { _C as C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).1.normal.js index 4814954e2497..d1024d13d7db 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).1.normal.js @@ -1,15 +1,35 @@ //// [usingDeclarationsWithLegacyClassDecorators.8.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - var C; + var _ts_decorate, _using_ctx, _C; _export("C", void 0); return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - _export("C", C = @dec - class C { - }); - using after = null + try { + var _usingCtx = _using_ctx(); + class C { + } + _export("C", _C = C); + C = _ts_decorate([ + dec + ], C); + var after = _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).2.minified.js index e7975bd6529e..b85e72b2b16e 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).2.minified.js @@ -1,12 +1,31 @@ //// [usingDeclarationsWithLegacyClassDecorators.8.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; return _export("C", void 0), { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - _export("C", @dec - class { - }); - using after = null + try { + var _usingCtx = _using_ctx(); + class C { + } + _export("C", C), C = _ts_decorate([ + dec + ], C), _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).1.normal.js index b3c66ba0fa17..a4bd4accb1a7 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).1.normal.js @@ -9,7 +9,18 @@ Object.defineProperty(exports, "default", { return C; } }); -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); +const _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(); + var C = class C { + }; + C = _ts_decorate._([ + dec + ], C); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).2.minified.js index 63a2c22842e8..6c68fbfb6168 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).2.minified.js @@ -7,7 +7,15 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -@dec -class C { +const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); +try { + var _usingCtx = _using_ctx._(), C = class { + }; + C = _ts_decorate._([ + dec + ], C), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).1.normal.js index 11fe9281f286..7084d7b2830d 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).1.normal.js @@ -1,5 +1,17 @@ //// [usingDeclarationsWithLegacyClassDecorators.9.ts] -export default @dec -class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +export { C as default }; +try { + var _usingCtx = _using_ctx(); + var C = class C { + }; + C = _ts_decorate([ + dec + ], C); + var after = _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).2.minified.js index 11fe9281f286..7110630aa11e 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).2.minified.js @@ -1,5 +1,15 @@ //// [usingDeclarationsWithLegacyClassDecorators.9.ts] -export default @dec -class C { +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +try { + var _usingCtx = _using_ctx(), C = class { + }; + C = _ts_decorate([ + dec + ], C), _usingCtx.u(null); +} catch (_) { + _usingCtx.e = _; +} finally{ + _usingCtx.d(); } -using after = null +export { C as default }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).1.normal.js index 94f1cab24712..a9d1eccb0f2b 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).1.normal.js @@ -1,15 +1,33 @@ //// [usingDeclarationsWithLegacyClassDecorators.9.ts] -System.register([], function(_export, _context) { +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { "use strict"; - var C; - _export("default", void 0); + var _ts_decorate, _using_ctx; return { - setters: [], + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - _export("default", C = @dec - class C { - }); - using after = null + try { + var _usingCtx = _using_ctx(); + var C = class C { + }; + _export("default", C = _ts_decorate([ + dec + ], C)); + var after = _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).2.minified.js index 160712158c13..b6ba6d8a9800 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).2.minified.js @@ -1,12 +1,30 @@ //// [usingDeclarationsWithLegacyClassDecorators.9.ts] -System.register([], function(_export, _context) { - return _export("default", void 0), { - setters: [], +System.register([ + "@swc/helpers/_/_ts_decorate", + "@swc/helpers/_/_using_ctx" +], function(_export, _context) { + var _ts_decorate, _using_ctx; + return { + setters: [ + function(_ts_decorate1) { + _ts_decorate = _ts_decorate1._; + }, + function(_using_ctx1) { + _using_ctx = _using_ctx1._; + } + ], execute: function() { - _export("default", @dec - class { - }); - using after = null + try { + var _usingCtx = _using_ctx(), C = class { + }; + _export("default", C = _ts_decorate([ + dec + ], C)), _usingCtx.u(null); + } catch (_) { + _usingCtx.e = _; + } finally{ + _usingCtx.d(); + } } }; }); diff --git a/crates/swc/tests/tsc.rs b/crates/swc/tests/tsc.rs index 9ad671bb19b5..0a336f354e0d 100644 --- a/crates/swc/tests/tsc.rs +++ b/crates/swc/tests/tsc.rs @@ -231,11 +231,9 @@ fn matrix(input: &Path) -> Vec { EsVersion::Es2020, EsVersion::Es2021, EsVersion::Es2022, + EsVersion::EsNext, ]); } - "esnext" => { - versions.insert(EsVersion::latest()); - } "es6" | "es2015" => { versions.insert(EsVersion::Es2015); }