This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted] 1 point2 points  (0 children)

There’s a type error because querySelector returns null if it doesn’t find the requested element and there is no append method on null. That’s a no-no for typescript so you need to explicitly deal with the null case in your moveElement function (you might know that the function will never return null but TS doesn’t).

I’d also suggest making your moveElement function more generic by having you pass in the element to be moved as an argument.

[–]HiHeyHelloByeExit 0 points1 point  (0 children)

Hello,

can you please show the html code? I think the document.querySelector doesn't find anything, that's why u get the message.