(Angular) How to fix Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'

How to fix Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'.  Type 'null' is not assignable to type 'HTMLElement'.

When you're facing this problem should add a null check. In typescript, you can set that this variable never become null by adding a    !   At the end.

Also, you may have the following error  Object is possibly 'null'



You can solve by adding  At the end.