mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix(cli): add hygiene pass to transpile pipeline (#8586)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
95ccc1a52f
commit
93d9f51d16
4 changed files with 56 additions and 0 deletions
|
@ -42,6 +42,7 @@ use swc_ecmascript::parser::Syntax;
|
|||
use swc_ecmascript::parser::TsConfig;
|
||||
use swc_ecmascript::transforms::fixer;
|
||||
use swc_ecmascript::transforms::helpers;
|
||||
use swc_ecmascript::transforms::hygiene;
|
||||
use swc_ecmascript::transforms::pass::Optional;
|
||||
use swc_ecmascript::transforms::proposals;
|
||||
use swc_ecmascript::transforms::react;
|
||||
|
@ -305,6 +306,7 @@ impl ParsedModule {
|
|||
helpers::inject_helpers(),
|
||||
typescript::strip(),
|
||||
fixer(Some(&self.comments)),
|
||||
hygiene(),
|
||||
);
|
||||
|
||||
let program = swc_common::GLOBALS.set(&Globals::new(), || {
|
||||
|
|
|
@ -2927,6 +2927,11 @@ itest!(no_check_decorators {
|
|||
output: "no_check_decorators.ts.out",
|
||||
});
|
||||
|
||||
itest!(runtime_decorators {
|
||||
args: "run --quiet --reload --no-check runtime_decorators.ts",
|
||||
output: "runtime_decorators.ts.out",
|
||||
});
|
||||
|
||||
itest!(lib_ref {
|
||||
args: "run --quiet --unstable --reload lib_ref.ts",
|
||||
output: "lib_ref.ts.out",
|
||||
|
|
42
cli/tests/runtime_decorators.ts
Normal file
42
cli/tests/runtime_decorators.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
// deno-lint-ignore-file
|
||||
function A() {
|
||||
console.log("@A evaluated");
|
||||
return function (
|
||||
target: any,
|
||||
propertyKey: string,
|
||||
descriptor: PropertyDescriptor,
|
||||
) {
|
||||
console.log("@A called");
|
||||
const fn = descriptor.value;
|
||||
descriptor.value = function () {
|
||||
console.log("fn() called from @A");
|
||||
fn();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function B() {
|
||||
console.log("@B evaluated");
|
||||
return function (
|
||||
target: any,
|
||||
propertyKey: string,
|
||||
descriptor: PropertyDescriptor,
|
||||
) {
|
||||
console.log("@B called");
|
||||
const fn = descriptor.value;
|
||||
descriptor.value = function () {
|
||||
console.log("fn() called from @B");
|
||||
fn();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
class C {
|
||||
@A()
|
||||
@B()
|
||||
static test() {
|
||||
console.log("C.test() called");
|
||||
}
|
||||
}
|
||||
|
||||
C.test();
|
7
cli/tests/runtime_decorators.ts.out
Normal file
7
cli/tests/runtime_decorators.ts.out
Normal file
|
@ -0,0 +1,7 @@
|
|||
@A evaluated
|
||||
@B evaluated
|
||||
@B called
|
||||
@A called
|
||||
fn() called from @A
|
||||
fn() called from @B
|
||||
C.test() called
|
Loading…
Reference in a new issue