Cannot Decorate Class Properties
See original GitHub issueWhen using babel-plugin-transform-class-properties
any decorated class property is undefined
function myDecorator(){
// Decorate stuff
}
...
class Person{
@myDecorator
age = 43; // Nope - doesn't work
@myDecorator
toString(){ // Yep - works
}
constructor(){
console.log(this.age) // undefined
}
}
Furthermore, the decorator is never called for the class property. Am I missing something?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Unable to access value using Property decorator in typescript
A Property Descriptor is not provided as an argument to a property decorator due to how property decorators are initialized in TypeScript. This ......
Read more >[v6] Cannot decorate ... the property is already ... - GitHub
This check fails, if the subclass only contains computed properties and no single observable variable. Modifying SubClass by adding a simple ...
Read more >Python Property Decorator - TutorialsTeacher
Learn what is decorator and property decorator. The property decorator allow us to define properties easily without calling the property() function ...
Read more >Documentation - Decorators - TypeScript
A property decorator cannot be used in a declaration file, or in any other ambient context (such as in a declare class). The...
Read more >Python Property Decorator - GeeksforGeeks
Which is used to return the property attributes of a class from the stated getter, setter and deleter as parameters. Now, lets see...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same issue as https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy/issues/24, your config has
transform-class-properties
listed beforetransform-decorators-legacy
, which is causing problems. Given your config, I’d dosince
stage-0
will covertransform-object-rest-spread
andtransform-class-properties
for you already.Sorry to post here but i have the same issue and I have the decorators-legacy plugin listed first.