-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Description
π Search Terms
"static this", "experimental decorators"
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about static
β― Playground Link
π» Code
function Decorator (target: Function, key: string | undefined, index: number) {}
class MyClass {
static readonly staticThisRef = this;
constructor(@Decorator foo: number) {}
}π Actual behavior
MyClass.staticThisRef = (void 0);
π Expected behavior
staticThisRef points to the class.
Additional information about the issue
Enabling or disabling experimentalDecorators fixes the issue.
With experimentalDecorators:
let MyClass = class MyClass {
constructor(foo) { }
};
MyClass.staticThisRef = (void 0);
MyClass = __decorate([
__param(0, Decorator)
], MyClass);Without experimentalDecorators:
class MyClass {
constructor(foo) { }
}
_a = MyClass;
MyCLass.staticThisRef = _a;
However only experimental decorators support decorating parameters.
Also TypeScript compiler behavior here is different from esbuild with experimentalDecorators feature enabled:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels