LaTeX.js icon indicating copy to clipboard operation
LaTeX.js copied to clipboard

new Macros need HtmlGenerator but "this" point to Generator in generator

Open seuliang opened this issue 6 years ago • 3 comments

https://github.com/michael-brade/LaTeX.js/blob/245ca82d22c9f9d4dc34041833316667b2f17af6/src/generator.ls#L84

function Macros in Generator class use "this" which point to Generator in typescript. but argument "this" should point to HtmlGenerator. Do you have ang suggestion how to handle this ?

seuliang avatar Jul 11 '19 14:07 seuliang

I don't understand this one... this points to the current class, and if that is HtmlGenerator (derived from Generator), then this is HtmlGenerator. Why should it be different in TypeScript?

michael-brade avatar Jul 11 '19 17:07 michael-brade

because argument type defined in function Macros is HtmlGenerator. "new Macros" in Generator takes "this" as Generator. so type check will fail.

i will try to disable TS type check here.

seuliang avatar Jul 12 '19 00:07 seuliang

ahhh. Yes, this is a thing I haven't fixed yet: Macros should NOT depend on HtmlGenerator, only on the Generator interface. So don't disable the type check there, just cast the Generator to HtmlGenerator and make Macros take a Generator.

michael-brade avatar Jul 12 '19 07:07 michael-brade