-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
access decorated class from itself #79
Comments
I think it should not invoke
This code only log once. For the
This code successfully prints
However this should throw a To reference the actual decorated subclass in method |
I see why my example is not actualy showing the problem. Your last is better const A = decorator(class B {
a() { return new A(); }
b() { return new B(); }
}) But still. |
It's pretty interesting why I believe the let decorator = x => class extends x {
bar() {
console.log('bar');
}
};
@decorator
class A {
foo() {
console.log(A); // outputs [Function: A]
let a = new A();
a.bar();
}
}
console.log(A); // outputs [Function: _class] but not [Function: A] I think it is because:
For language itself, I think there should be cases where we need both the original version and decorated version of class, a good example is C# which has both virtual and non-virtual methods along with |
To addition, there is a more tricky way to access both original and decorated version of class: let B = @decorator class A {
foo() {
console.log(A); // Original one
console.log(B); // Decorated one
}
};
let a = new B();
a.foo(); It's the same as apply decorator manually |
When you have decorated class, from inside that class should you be able to access decorated or original version of it?
For example.
The text was updated successfully, but these errors were encountered: