Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distribute typescript definitions #3531

Open
tobiasdiez opened this issue Jan 30, 2022 · 6 comments · May be fixed by #3846
Open

Distribute typescript definitions #3531

tobiasdiez opened this issue Jan 30, 2022 · 6 comments · May be fixed by #3846

Comments

@tobiasdiez
Copy link

tobiasdiez commented Jan 30, 2022

Is your feature request related to a problem? Please describe.
When using katex in typescript, one has to use the @types/katex package to get some type interference. However, these type definitions are quite minimal.

Describe the solution you'd like:
Provide full typescript definitions automatically.

Describe alternatives you've considered:
Using @types/katex.

Additional context:
https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html

@edemaine
Copy link
Member

Thanks for the pointers and suggestion. Here are the @types/katex type definitions.

An advantage of publishing them ourselves is we can update them together with KaTeX versioning (though it's pretty rare for them to change, we might add an option or two). Overall it seems like a good idea, related to #2110.

@jameshfisher
Copy link
Contributor

The @types/katex type definitions seem completely broken. Katex as of v0.15 seems to have only a default export, so I have to import katex from 'katex'. But the type definitions demand that I import * as katex from 'katex', which is completely different.

@jameshfisher
Copy link
Contributor

Note that those definitions seemed to work with Katex v0.13, but have been broken somewhere between v0.13 and v0.15.

@jameshfisher
Copy link
Contributor

It appears this was a breaking change in v0.14: https://github.com/KaTeX/KaTeX/blob/main/CHANGELOG.md

@Mister-Hope
Copy link

Mister-Hope commented Nov 17, 2022

I am not sure who is maintaining type files, but due to microsoft/TypeScript#50690, types are broken with esm.

"type": "module",

needs to be added in @types/katex package.json to fix this

@edemaine
Copy link
Member

Is someone on this thread willing to put together a PR to add a .d.ts file to this repository? It would be greatly appreciated!

@kelvinsjk kelvinsjk linked a pull request Aug 7, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants