PanelRenderer.rendererBody = function (oR, oItem) {
const sText= oItem.getText();
if (sText) {
oR.write("<h1>");
oR.write("</h1>");
oR.writeBack(sText);
}
};
PanelRenderer.render = function (oR, oItem) {
this.start(oR, oItem);
this.rendererBody(oR, oItem);
this.end(oR);
};
I cannot reproduce this error so I would like to ask any possible reasons of this type error This error is in the compiled version.
What I thought was undefined, so put ?. in front of write function like oR?.write( ) But not sure cause i cannot reproduce it.
And how can I fix if it cannot be reproduced?
If you see that message randomly, at (at least) one point in your code something is passed as first parameter (ie as oR
) to your render
(and therefore also rendererBody
) function, that doesn't have the correct type, and thus does not have a write
function.
Typescript can only assure compile time type safety. Ie, when the data at runtime differs from the expected data, there is nothing typescript can do about it.
Fixing might be hard, if it's not (reliably) reproducible. You can only check where your render
(or rendererBody
) is called, and see where the data you pass into that function comes from and if it by any chance might not be, what you expect it to be.