Skip to content

Instantly share code, notes, and snippets.

@Yelmor
Last active August 27, 2019 07:59
Show Gist options
  • Select an option

  • Save Yelmor/1970febe28435e82cd049651c7047d70 to your computer and use it in GitHub Desktop.

Select an option

Save Yelmor/1970febe28435e82cd049651c7047d70 to your computer and use it in GitHub Desktop.
typescript decorator run order
function Mark(message: string) {
console.log('create', message);
return function (target: any, propertyKey?: string | symbol, propertyDescriptionOrIndex?: PropertyDescriptor | number) {
console.log('run', message);
}
}
@Mark('A')
class A {
@Mark('A.m0')
m0(
@Mark('A.m0.p0') p0,
@Mark('A.m0.p1') p1
) {}
@Mark('A.k0')
k0: number;
@Mark('A.m1')
m1(
@Mark('A.m1.p0') p0,
@Mark('A.m1.p1') p1
) {}
@Mark('A.k1')
k1: number;
}
/**
create A.m0
create A.m0.p0
create A.m0.p1
run A.m0.p1
run A.m0.p0
run A.m0
create A.k0
run A.k0
create A.m1
create A.m1.p0
create A.m1.p1
run A.m1.p1
run A.m1.p0
run A.m1
create A.k1
run A.k1
create A
run A
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment