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.

Decorators are broken in 7

See original GitHub issue

Bug Report

Current Behavior Follow up to https://github.com/babel/babel/issues/7786 . No idea why that issue is closed, with a cliff-hanger. If you add {legacy: true} option to the plugin, you’ll again get the error about the syntax not being enabled.

Input Code

@observer
class TextInput {}

Expected behavior/code It works

Babel Configuration (.babelrc, package.json, cli command)

{
  plugins: [
    ...,
    ['@babel/plugin-proposal-decorators', {legacy: true}],
  ],
}

Environment

  • Babel version(s): [v7.0.0-beta.46]
  • Node/npm version: [e.g. Node 9.2.1/yarn 1.5.1]
  • Monorepo [e.g. no]
  • How you are using Babel: [loader]

Additional context/Screenshots So basically it goes like this:

First you get a warning Support for the experimental syntax 'decorators' isn't currently enabled. You add '@babel/plugin-proposal-decorators' to your plugins, you then get a warning about needing legacy option, you add the legacy option and you’re back at Support for the experimental syntax 'decorators' isn't currently enabled warning.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:21
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

19reactions
kiwicopplecommented, Apr 4, 2019

Here is an example babel.config.js (you should delete .babelrc):

module.exports = function(api) {
  api.cache(true)
  return {
    presets: ['next/babel'],
    plugins: [
      ['@babel/plugin-proposal-decorators', { legacy: true }],
      ['@babel/plugin-proposal-class-properties', { loose: true }],
    ],
  }
}
4reactions
taystackcommented, Jan 9, 2019

So I figure it out by not using .babelrc at all, and instead using babel.config.js 😃

Could you elaborate a bit more on this @abologna-r7 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Please Fix Your Decorators - Hynek Schlawack
Sadly most decorators are broken because the web is full of bad advice. (Feel free to jump directly to the conclusion if you...
Read more >
"Class is using Angular features but is not decorated. Please ...
Q: Angular components broken - "Class is using Angular features but is not decorated. Please add an explicit Angular decorator" · Ask Question....
Read more >
Primer on Python Decorators
In this introductory tutorial, we'll look at what Python decorators are and how to create and use them.
Read more >
Cake Decorator Jobs, Employment in Oklahoma | Indeed.com
Shift Leader/Cake Decorator. Marble Slab Creamery & Great American Cookies. Broken Arrow, OK. Estimated $18.4K - $23.3K a year. Full-time +1.
Read more >
Memphis Light Oak 8 mm Thick x 7-2/3 in. Wide x 50-5/8 in ...
Home Decorators Collection Memphis Light Oak has rich gray color tones and deep graining that present a warm and inviting look to complement...
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