Text On
Home
Angular
Error
Typescript
(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'

(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'

May 20, 2022
0 Comments

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.



Comments

Post a Comment