-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Open
Labels
bugSomething isn't workingSomething isn't workingtypescriptSomething for TypeScriptSomething for TypeScript
Description
What version of Bun is running?
1.2.15
What platform is your computer?
Microsoft Windows NT 10.0.26100.0 x64
What steps can reproduce the bug?
The decorator seems to lose context information.
When executing "bun xxx.ts" with decorators, it shows different results from "bun xxx.js" compiled by tsc.
note: "originalMethod" also gets the same problem.
my test code: tmp.zip
function loggedMethod(originalMethod: any, context: ClassMethodDecoratorContext) {
const methodName = String(context.name);
console.log(`🔍 自动日志装饰器应用于方法: ${methodName}`);
function replacementMethod(this: any, ...args: any[]) {
console.log(`LOG: Entering method '${methodName}'.`)
const result = originalMethod.call(this, ...args);
console.log(`LOG: Exiting method '${methodName}'.`)
return result;
}
return replacementMethod;
}
class ExampleClass {
@loggedMethod
foo() {
console.log("foo 方法执行完毕");
}
}
new ExampleClass().foo();What is the expected behavior?
Hope "bun xxx.ts" can correctly process decorator context values.
In ".ts" file, "methodName" should be log correctly like ".js" files.
What do you see instead?
Additional information
deanrihOcyss
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtypescriptSomething for TypeScriptSomething for TypeScript

