-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Closed
Description
Bug report
What is the current behavior?
I try to write a class A that instantiate an object B that inherit from A?
I get the following error on runtime
a.js:3 Uncaught ReferenceError: Cannot access 'A' before initialization
at Module.default (a.js:3:56)
at eval (b.js:3:32)
at ./src/js/b.js (bundle.425598c….js:723:1)
at __webpack_require__ (bundle.425598c….js:1278:41)
at eval (a.js:5:63)
at ./src/js/a.js (bundle.425598c….js:712:1)
at __webpack_require__ (bundle.425598c….js:1278:41)
at eval (index.js:2:63)
at ./src/js/index.js (bundle.425598c….js:821:1)
at __webpack_require__ (bundle.425598c….js:1278:41)
If the current behavior is a bug, please provide the steps to reproduce.
I use 3 files:
index.js
import A from "./a.js";
let a = new A();
a.fct();
a.js
import B from "./b.js"
export default class A {
constructor() {
console.log ("a constructor")
}
fct() {
this.b = new B();
}
}
b.js
import A from "./a.js"
export default class B extends A {
constructor() {
console.log ("b constructor")
}
}
What is the expected behavior?
It shouldn't trigger an error at runtime. Since this is technically possible in JS as prooven on this JSFiddle
Other relevant information:
webpack version: 5.82.0
Node.js version: 18.16.0
Operating System: Ubuntu 22.04
Additional tools: -
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels