Skip to content

How to use MathJax in TypeScript project? #2385

Closed
@ghost

Description

I built a custom combined component file with a modified subclass of the output jax CHTML and incorporated it into my project. My combined component file custom-component.js is written in plain JavaScript, just like the examples in the MathJax-demos-web repo. I included my webpacked custom-component.min.js with a <script> tag in my index.html and everything worked fine. I used JavaScript in my other scripts in index.html as well.
Now, however, I am looking to move to TypeScript, since now that I have made the connection to MathJax by being able to configure and access the output jax in the ways I want, I am ready to write my own code, and that, I want to do in TypeScript.
That's why I am looking to get rid of all the plain JavaScript in my index.html and move all the logic (and MathJax loading) to an index.ts file.
That's where I am running into problems though. Since I would like to have just a single <script> tag that I need to include in my index.html, I want even the MathJax loading to be done in my index.ts. And although I can import my own combined component file, I can't setup the global MathJax object because TypeScript does not recognize it.
I looked into the code a little bit about how the global is set up, but I don't understand how to solve my problem anyway.

My question now is, what I am doing wrong here. Am I taking a wrong approach? Should I rewrite my custom component file to be a TypeScript file and not a plain JavaScript one? And also, why were all the components written in JavaScript and not in TypeScript like the rest of the project? Is there some easy way to connect to the MathJax source with a TypeScript project like mine?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions