Skip to content
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

referenced static property in class instance throws ReferenceError #11990

Closed
dnalborczyk opened this issue Aug 21, 2020 · 2 comments
Closed

referenced static property in class instance throws ReferenceError #11990

dnalborczyk opened this issue Aug 21, 2020 · 2 comments
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Spec: Class Fields

Comments

@dnalborczyk
Copy link
Contributor

dnalborczyk commented Aug 21, 2020

Bug Report

Current behavior

the below code throws ReferenceError: B is not defined.

It works natively in node.js (latest/14.8.0) as well as TypeScript (latest/4.0)

Input Code

npx babel-node a.js
// b.js
exports.b = new (class B {
  static a = 0

  static b = B.a

  getB() {
    return B.b
  }
})()
// a.js
const { b } = require('./b.js')

console.log(b.getB())

// ReferenceError: B is not defined

Workaround

// b.js
class B {
  static a = 0

  static b = B.a

  getB() {
    return B.b
  }
}

exports.b = new B()

Expected behavior

should not throw an error.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
'@babel/plugin-transform-typescript', {
    allowDeclareFields: true,
},
'@babel/plugin-proposal-class-properties',
  • Babel version(s):
    "@babel/cli": "7.10.5",
    "@babel/core": "7.11.4",
    "@babel/node": "7.10.5",
    "@babel/plugin-proposal-class-properties": "7.10.4",
    "@babel/plugin-transform-typescript": "7.11.0",

  • Node/npm version: 14.8.0

  • OS: macOS 10.15.6

@babel-bot
Copy link
Collaborator

Hey @dnalborczyk! 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 community that typically always has someone willing to help. You can sign-up here for an invite."

@dnalborczyk dnalborczyk changed the title referenced static property in instantiated class throws ReferenceError when directly exported referenced static property in instantiated class throws ReferenceError Aug 21, 2020
@dnalborczyk dnalborczyk changed the title referenced static property in instantiated class throws ReferenceError referenced static property in class instance throws ReferenceError Aug 21, 2020
@nicolo-ribaudo
Copy link
Member

Fixed by #13429

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 17, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Spec: Class Fields
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants