LaTeX.js
LaTeX.js copied to clipboard
Code-Questions for a TypeScript-Implementation
see: https://github.com/michael-brade/LaTeX.js/blob/245ca82d22c9f9d4dc34041833316667b2f17af6/src/html-generator.ls#L299
https://github.com/michael-brade/LaTeX.js/blob/245ca82d22c9f9d4dc34041833316667b2f17af6/src/html-generator.ls#L352
https://github.com/michael-brade/LaTeX.js/blob/245ca82d22c9f9d4dc34041833316667b2f17af6/src/html-generator.ls#L487
those functions adapt different arguments, how to decide arguments's type?
appendChildis part of the Browser DOM API (seeNode.appendChild()).appendChildrenis takingNodeandArray<Node>|NodeaddAttributes: you could just read the code... theifwill tell you:Element|Text|DocumentFragmentorArray<Element>.createDocument: takes an Array ofElementto create the final DOM.
You know, we could use this issue, for example, to group all your TypeScript questions. Then we don't have to use many different issues and all the information can be found on one page... I'll change the title accordingly.
i agree .it's will be convenient.
i tried some types for those arguments but not appropriate for all conditions. i just want to confirm those types. i will try again. Thank you !
https://github.com/michael-brade/LaTeX.js/blob/245ca82d22c9f9d4dc34041833316667b2f17af6/src/html-generator.ls#L299
@_dom is DocumentFragment,
https://github.com/michael-brade/LaTeX.js/blob/245ca82d22c9f9d4dc34041833316667b2f17af6/src/html-generator.ls#L497
"nodes" in "Text" and "DocumentFragment" type is not consistent to "create" argument type Element or an array of Element
Ok, so simply change/extend the type definition for create: children type should equal the one of appendChildren or be more restrictive than it (appendChildren could even take Node or Array<Node>). However, don't confuse the type and children arguments of create.
actually, I edited appendChildren in my earlier comment (https://github.com/michael-brade/LaTeX.js/issues/81#issuecomment-510588382), there is no need to be more restrictive with the types than necessary.
yes. i understand. I have done some type definitions, but need more time to finish the rest and do some documentation to help me understand it.
Hey there! I would be interested in type definitions for this package Do you have a link to a repository or gist ?
:beers: thank you!