-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
fix: should respect legacy decorators
Showing
7 changed files
with
1,424 additions
and
1,234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,23 @@ | ||
const printMemberName = (target: any, memberName: string) => { | ||
console.log(memberName); | ||
}; | ||
|
||
class Person { | ||
// @ts-expect-error | ||
@printMemberName | ||
name: string = "Jon"; | ||
} | ||
function trace(value, {kind, name}) { | ||
if (kind === 'method') { | ||
return function (...args) { | ||
console.log('trace') | ||
return value.apply(this, args); | ||
}; | ||
} | ||
} | ||
|
||
class People { | ||
xzy: string | ||
constructor(){ | ||
this.xzy = 'xzy'; | ||
} | ||
@trace | ||
test() { | ||
return this.xzy | ||
} | ||
} | ||
|
||
const p = new People(); | ||
|
||
p.test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function trace(_target: any, _name: string, descriptor: PropertyDescriptor) { | ||
const original = descriptor.value; | ||
descriptor.value = function () { | ||
console.log('trace'); | ||
return original.call(this); | ||
}; | ||
|
||
return descriptor; | ||
} | ||
|
||
class People { | ||
xzy: string; | ||
constructor() { | ||
this.xzy = 'xzy'; | ||
} | ||
|
||
@trace | ||
test() { | ||
return this.xzy; | ||
} | ||
} | ||
|
||
const p = new People(); | ||
|
||
p.test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2017", | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"module": "ES2022", | ||
"baseUrl": "./" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters