Class properties work differently with transform-decorators-legacy
See original GitHub issueTurning on transform-decorators-legacy will cause errors if you use class properties in a specific way.
class Foo {
static SECOND = 1000;
static MINUTE = Foo.SECOND * 60;
}
This will say that Foo is undefined while trying to evaluate Foo.SECOND
. Without the decorators-legacy plugin this works.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:10
- Comments:21 (6 by maintainers)
Top Results From Across the Web
Plugins - Babel.js
Will run transform-decorators-legacy then transform-class-properties . It is important to remember that with presets, the order is reversed. The following: { " ...
Read more >babel-plugin-transform-decorators-legacy - npm package - Snyk
Static class property initializers are evaluated once up front. If you decorate a static class property, you will get a descriptor with an...
Read more >Gulp / ES2015 / React Unexpected @ and transform-decorators
I have installed "babel-plugin-transform-decorators-legacy": "^1.3.4",. I've tried to use the stage-x presets only to get Decorators are ...
Read more >Documentation - Decorators - TypeScript
A Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. Decorators use...
Read more >JavaScript Decorators: What They Are and When to Use Them
The decorator proposal adds support for class and property decorators that can be used to resolve these issues, and future JavaScript versions ...
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
Okay! Given the results in https://github.com/jeffmo/es-class-fields-and-static-properties/issues/40, I’ll change this to work better. I won’t be able to get to it right away though.
@mattinsler If you’re manually specifying your plugins, the order sometimes matter. Make sure
transform-decorators-legacy
comes beforetransform-class-properties
.