New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@babel/plugin-proposal-decorators doesn't support kind: "initializer" #9260

tjcrowder opened this Issue Dec 29, 2018 · 2 comments


None yet
3 participants
Copy link

tjcrowder commented Dec 29, 2018

Bug Report

Don't know if this should be a bug report or a feature request. Apologies if it should be the latter, but since the plugin is out there... I couldn't find an existing bug report for this either.

Current Behavior
At present, trying to create a kind: "initializer" element descriptor (added in November in PR#165) causes an error:

TypeError: An element descriptor's .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "initializer"

Input Code

"use strict";

function example(ed) {
    console.log(`converting ${ed.key} to initializer`);
    return {
        kind: "initializer",
        placement: "own",
        initializer() {
            console.log("initializer ran");

class Foo {
    @example x = 1;

new Foo;

(Can't provide REPL link since the plugin requires an option, and the REPL doesn't have a means of setting options AFAIKT.)

Expected behavior/code
Expected the initializer to run and for x not to be created on the instance.

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


  "presets": [
        "targets": {
          "chrome": "70"
  "plugins": [
    ["@babel/plugin-proposal-decorators", {"decoratorsBeforeExport": false}],


  "name": "decorators-bugreport",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "babel src -d lib"
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "@babel/cli": "^7.2.3",
    "@babel/core": "^7.2.2",
    "@babel/plugin-proposal-class-properties": "^7.2.3",
    "@babel/plugin-proposal-decorators": "^7.2.3",
    "@babel/plugin-proposal-private-methods": "^7.2.3",
    "@babel/preset-env": "^7.2.3"

Built using npm run build.


  • Babel version(s): v.7.2.3 for everything except @babel/core, which is v7.2.2
  • Node/npm version:Node 11.3.0/npm 5.3.0
  • OS: Linux Mint
  • Monorepo: No
  • How you are using Babel: cli

As always, thank you for the work you do on Babel and the plugins. Hope to help at some point.


This comment has been minimized.

Copy link

babel-bot commented Dec 29, 2018

Hey @tjcrowder! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
that typically always has someone willing to help. You can sign-up here
for an invite.


This comment has been minimized.

Copy link

nicolo-ribaudo commented Dec 29, 2018

We are implementing it at #9008 (but it is blocked by #9166)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment