question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Class properties work differently with transform-decorators-legacy

See original GitHub issue

Turning 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:open
  • Created 8 years ago
  • Reactions:10
  • Comments:21 (6 by maintainers)

github_iconTop GitHub Comments

9reactions
loganfsmythcommented, Jun 23, 2016

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.

9reactions
jayphelpscommented, Jun 23, 2016

@mattinsler If you’re manually specifying your plugins, the order sometimes matter. Make sure transform-decorators-legacy comes before transform-class-properties.

WRONG!!

"plugins": [
  "transform-class-properties",
  "transform-decorators-legacy"
]

RIGHT

"plugins": [
  "transform-decorators-legacy",
  "transform-class-properties"
]
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found