1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-29 16:30:56 -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:
János Veres 2020-12-02 20:26:04 +01:00 committed by GitHub
parent 95ccc1a52f
commit 93d9f51d16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 0 deletions

View file

@ -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(), || {

View file

@ -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",

View 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();

View file

@ -0,0 +1,7 @@
@A evaluated
@B evaluated
@B called
@A called
fn() called from @A
fn() called from @B
C.test() called