Skip to content

Unnecessary variable injected by class-properties plugin #6916

@nicolo-ribaudo

Description

@nicolo-ribaudo

Choose one: is this a bug report or feature request?

Input Code

var foo = "bar";

let Foo = class Foo {
  bar = foo;

  constructor() {
    var foo = "foo";
  }
};

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

{
  "presets": ["@babel/stage-3"]
}

Current Behavior

https://babeljs.io/repl/build/master#?babili=false&browsers=&build=&builtIns=false&code_lz=G4QwTgBAZg9jEF4ICIBG5kG4BQ2A2ApgC4QBiciEAxniAM51kUDe2EE6kSsMOb1MAHZ0iYAK5UiMMAAoAlBFbt2oSD0rIeWfgF9sOnEA&debug=false&circleciRepo=&evaluate=false&lineWrap=false&presets=stage-3&prettier=false&targets=&version=7.0.0-beta.32

var _class, _temp, _initialiseProps;

var foo = "bar";
let Foo = (_temp = _class = class Foo {
  constructor() {
    _initialiseProps.call(this);

    var foo = "foo";
  }

}, _initialiseProps = function () {
  Object.defineProperty(this, "bar", {
    configurable: true,
    enumerable: true,
    writable: true,
    value: foo
  });
}, _temp);

The _class variable shouldn't be added.

Your Environment

(Found in repl, not tested locally)

software version(s)
Babel 7.0.0-beta.32
Babylon
node
npm
Operating System

Metadata

Metadata

Assignees

No one assigned

    Labels

    Spec: Class FieldsoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions