`calculateNecessaryParentheses` blows up cryptically when `getPrecedence` returns null
I accidentally created a node with the fn name mult instead of multiply i.e. new OperatorNode('*', 'mult', [...]), and when I went to tex-ify it I got the error Cannot read property 'OperatorNode:mult' of undefined which I found quite cryptic and took quite a bit of digging to figure out.
Is there a reason why getPrecedence returns null instead of throwing an error when precedence can't be determined? If so what would you recommend as a fix, if not could I change that?
The function getPrecedence(node, parenthesis) can be executed with any node type. Precedence does not have a meaning for all types of nodes: it is relevant for operators and assignment, but has no meaning for a constant or symbol for example. So I think it makes sense to return null in those cases: it's not an exception but "normal" behavior that some nodes do not have a precedence.
It would be good to see why toTex throws an exception when having an unknown type of OperatorNode, I think it shouldn't. Or if there is a good reason, we should improve the error message. I tried the following but cannot yet reproduce your issue:
console.log(new math.OperatorNode('*', 'mult', [
new math.ConstantNode(2),
new math.ConstantNode(3)
]).toTex())
// '2*2'