Referencing a private member E.G. this.#rts()
gives the error:
SyntaxError: Private field '#rts' must be declared in an enclosing class
Although when that line is evaluated, the function has been assigned to an instance method and this is correctly bound.
Is there a way to achieve this, I.E. to reference private members across files?
Note: I'm using Node 13.
Example:
import {Cpu6502} from "./cpu6502.mjs";
console.log((new Cpu6502).beq());
cpu6502.mjs:
import {beq} from "./instructions.mjs";
export class Cpu6502 {
beq = beq // `this` is correctly bound
#rts = () => "RTS"
}
instructions.mjs:
export function beq() {
return this.#rts() // If this line references a public member instead,
// it works fine and `this` is correctly bound.
}