Mathjax: The typescript compiler complains about MathJax

Created on 21 Oct 2020  路  6Comments  路  Source: mathjax/MathJax

Issue Summary

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.

Steps to Reproduce:

I have prepared a minimal working example to reproduce this problem

  1. git clone https://github.com/albertodiazdorado/mathjax.git
  2. cd mathjax
  3. yarn install
  4. node src/main.js --> works correctly!
  5. yarn run compile (or just tsc -p tsconfig.json, if you have tsc installed in your machine) --> fails badly

I do not know whether this is a bug, or I am doing some bad mistake with typescript.

Technical details:

  • MathJax Version: 2.3
  • Node Version: 14.4.0
  • Client OS: 5.8.16-2-MANJARO

Supporting information:

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...

Accepted Merged Test Not Needed v3

All 6 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DibasDauliya picture DibasDauliya  路  6Comments

geajack picture geajack  路  6Comments

lk-geimfari picture lk-geimfari  路  5Comments

cebola2 picture cebola2  路  3Comments

mt4c picture mt4c  路  3Comments