A Javascript numerical library to represent numbers as large as 10^^1e308 and as small as 10^-10^^1e308. Sequel to break_infinity.js, designed for incremental games.
MIT License
120
stars
43
forks
source link
Throws a TypeError with standard EcmaScript class fields #169
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.
What is the issue?
Break eternity uses static class fields to initialize the Decimal constants like:
FC_NN` is defined as:
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 likeUncaught 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.