I have been using MathJax for a while in a JS only project. Now we are willing to start our migration to TS, but the MatJax dependency will just not compile.
I have prepared a minimal working example to reproduce this problem
git clone https://github.com/albertodiazdorado/mathjax.git
cd mathjax
yarn install
node src/main.js
--> works correctly!yarn run compile
(or just tsc -p tsconfig.json
, if you have tsc
installed in your machine) --> fails badlyI do not know whether this is a bug, or I am doing some bad mistake with typescript.
I am going to copy here the most prominent error message, just in case someone gets the same error as me and tries to google it:
'factory' is defined as an accessor in class 'AbstractNode', but is overridden here in 'AbstractMmlNode' as an instance property.
If I inspect the code, it turns out true. The class AbstractNode
(whatever it is) defines factory
as a getter ("accessor"). Then, the class AbstractMmlNode
, which extends AbstractNode
, tries to re-define factory
as an instance variable...
Your package.json calls for Typescript 4.0.3, while the MathJax package.json requests version 3.9.7. There are several breaking changes in the 4.0 version of Typescript, and one of them is with getters/setters being overridden, which is what you are seeing, here. We are aware of the issue and will be fixing it for the next release, but for now, you need to use Typescript 3.9 with MathJax.
The pull requests mathjax/MathJax-src#560 and mathjax/MathJax-src#590 should resolve this issue.
Hi @dpvc , just to be sure that I understand correctly the development cycle of this mathjax. Even if the PRs are merged, they cannot be used yet, since they will be part of 3.1.3
and the most recent version right now is 3.1.2
. Am I right?
Thanks for the help!
@albertodiazdorado, you should be able to cherry-pick the commits for those two PRs (or rebase them and merge the results), as the changes are self-contained and should not affect anything else. I haven't tried it, but I don't think there should be merge conflicts. You can't just merge the commits themselves, since they are based off of develop that would contain lots of 3.1.3 changes that you would not want to include.
Thanks for the clarification. I will wait for the next release though, but thank you very much!
@albertodiazdorado, we are closing in on 3.1.3. Just a few more code reviews, and a small handful of minor fixes remain.