-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
What is the issue?
Break eternity uses static class fields to initialize the Decimal constants like:
public static readonly dZero = FC_NN(0, 0, 0);
FC_NN` is defined as:
let FC_NN = function FC_NN(sign: number, layer: number, mag: number) {
return Decimal.fromComponents_noNormalize(sign, layer, mag);
};
Decimal.fromComponents_noNormalize
invokes the Decimal class constructor (new Decimal()
).
But apparently static class fields initializers run before the class is ready to be used as a constructor which causes it to throw a TypeError.
How to reproduce?
Clone this repository, in tsconfig.json change target to "esnext"
, transpile the library source code using tsc and run the output file in literally any JS runtime that supports ES2022 and you shouldsee an error like Uncaught ReferenceError: can't access lexical declaration 'Decimal' before initialization
note: I feel like this isn't a very great explantion of all this, if you need further info just ask me.
Metadata
Metadata
Assignees
Labels
No labels