My experience with TypeScript is still new, and I recently found myself confused when trying to apply inline CSS to a tag on click. I initially thought it would be simple, but in TypeScript, things seem to work differently. I attempted to use
document.querySelector("html").style.background = "blue"
, but encountered an error:
Object is possibly 'null'. TS2531
jumpToRelativePosition(anchors['chapter-main'], anchors['chapter-next']);
document.querySelector("html").style.background = "blue
"
^
I am seeking assistance to resolve this issue.
Thank you in advance.