WarnerHooh / babel-plugin-parameter-decorator

Function parameter decorator transform plugin for babel v7, just like typescript.
34 stars 9 forks source link

Wrong running order #17

Open replace5 opened 4 years ago

replace5 commented 4 years ago

`function ClassDecorator() { return function (target) { console.log("I am class decorator"); }; } function MethodDecorator() { return function (target, methodName: string, descriptor: PropertyDescriptor) { console.log("I am method decorator"); }; } function Param1Decorator() { return function (target, methodName: string, paramIndex: number) { console.log("I am parameter1 decorator"); }; } function Param2Decorator2() { return function (target, methodName: string, paramIndex: number) { console.log("I am parameter2 decorator2"); }; } function MethodDecorator2() { return function (target, methodName: string, descriptor: PropertyDescriptor) { console.log("I am method decorator2"); }; } function Param1Decorator2() { return function (target, methodName: string, paramIndex: number) { console.log("I am parameter1 decorator2"); }; } function Param2Decorator() { return function (target, methodName: string, paramIndex: number) { console.log("I am parameter2 decorator"); }; } function PropertyDecorator() { return function (target, propertyName: string) { console.log("I am property decorator"); }; }

@ClassDecorator() class Hello { @MethodDecorator2() greet2(@Param1Decorator2() p1: string, @Param2Decorator2() p2: string) { }

@PropertyDecorator()
greeting: string = "test";

@MethodDecorator()
greet(@Param1Decorator() p1: string, @Param2Decorator() p2: string) { }

}`

run after babel-plugin-parameter-decorator compile

I am parameter1 decorator2 I am parameter2 decorator2 I am parameter1 decorator I am parameter2 decorator I am method decorator2 I am property decorator I am method decorator I am class decorator

run on typescript playground: https://www.typescriptlang.org/play/?noImplicitAny=false&alwaysStrict=false&declaration=false&experimentalDecorators=true&target=7#

I am parameter2 decorator2 I am parameter1 decorator2 I am method decorator2 I am property decorator I am parameter2 decorator I am parameter1 decorator I am method decorator I am class decorator