diff options
-rw-r--r-- | cli/ast.rs | 6 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 5 | ||||
-rw-r--r-- | cli/tests/ts_decorators_bundle.out | 3 | ||||
-rw-r--r-- | cli/tests/ts_decorators_bundle.ts | 22 |
4 files changed, 35 insertions, 1 deletions
diff --git a/cli/ast.rs b/cli/ast.rs index 44e5616e7..bc7265c15 100644 --- a/cli/ast.rs +++ b/cli/ast.rs @@ -467,7 +467,11 @@ pub fn transpile_module( typescript::strip(), fixer(Some(&comments)), ); - let module = module.fold_with(&mut passes); + let module = swc_common::GLOBALS.set(&Globals::new(), || { + helpers::HELPERS.set(&helpers::Helpers::new(false), || { + module.fold_with(&mut passes) + }) + }); Ok((source_file, module)) } diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 895c64098..979a2ffad 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2637,6 +2637,11 @@ itest!(ts_decorators { output: "ts_decorators.ts.out", }); +itest!(ts_decorators_bundle { + args: "bundle ts_decorators_bundle.ts", + output: "ts_decorators_bundle.out", +}); + itest!(ts_type_only_import { args: "run --reload ts_type_only_import.ts", output: "ts_type_only_import.ts.out", diff --git a/cli/tests/ts_decorators_bundle.out b/cli/tests/ts_decorators_bundle.out new file mode 100644 index 000000000..3a152aecc --- /dev/null +++ b/cli/tests/ts_decorators_bundle.out @@ -0,0 +1,3 @@ +[WILDCARD] +new SomeClass().test(); +[WILDCARD]
\ No newline at end of file diff --git a/cli/tests/ts_decorators_bundle.ts b/cli/tests/ts_decorators_bundle.ts new file mode 100644 index 000000000..a8e2e952b --- /dev/null +++ b/cli/tests/ts_decorators_bundle.ts @@ -0,0 +1,22 @@ +/* eslint-disable */ + +function Decorator() { + return function ( + target: Record<string, any>, + propertyKey: string, + descriptor: TypedPropertyDescriptor<any>, + ) { + const originalFn: Function = descriptor.value as Function; + descriptor.value = async function (...args: any[]) { + return await originalFn.apply(this, args); + }; + return descriptor; + }; +} + +class SomeClass { + @Decorator() + async test(): Promise<void> {} +} + +new SomeClass().test(); |