Bug Report
Current behavior
When accessing a get /set accessor before it's descriptor is created by the emitted code causes the error TypeError Cannot read property 'get' of undefined
REPL
Input Code
class AA {
static #x = new AA();
static get #y() { return 0; }
static set #y(value) { }
constructor() {
// Either will cause the error
console.log(AA.#y);
//AA.#y = 10
}
}
Expected behavior
This should work. It works in node.
Possible Solution
Reorder the emit to put private static accessors before fields. Accessor declarations do not have side effects so it is safe to execute them first. After, we can emit static fields, which can have side effects, safely, and any dependency on the static private accessors will work correctly.
Bug Report
Current behavior
When accessing a get /set accessor before it's descriptor is created by the emitted code causes the error
TypeError Cannot read property 'get' of undefinedREPL
Input Code
Expected behavior
This should work. It works in node.
Possible Solution
Reorder the emit to put private static accessors before fields. Accessor declarations do not have side effects so it is safe to execute them first. After, we can emit static fields, which can have side effects, safely, and any dependency on the static private accessors will work correctly.