maxeth / react-type-animation

A React typewriter animation based on typical with extended functionality and customization.
https://react-type-animation.netlify.app/
MIT License
427 stars 24 forks source link

sequence callback function parameter implicitly has any type #47

Closed MeDarwin closed 11 months ago

MeDarwin commented 11 months ago

in the docs, it says if you use useRef hooks, it has generic type from react createRef and the default is HTMLSpanElement. however when I do it the callback function way, the parameter has the type of any and it seems like I cannot infer the type to anything including HTMLElement as it doesnt satisfy the Sequence type in <TypeAnimation /> props.

Is there any way I can infer the parameter type from any to any HTMLElement in callback function?

MeDarwin commented 11 months ago

I solved the issue by adding or null into the type as the parameter in callback function can be null. so the callback function is written like this:

(el: HTMLElement | null) => {
    console.log(el)
}