I want to add local variable in Angular but error occur "type 'string null' is not assignable to type 'string'. typescript"

612 Views Asked by At

This is an image what exactly, i am facing the problem "type 'string null' is not assignable to type 'string'. typescript"

enter image description here

2

There are 2 best solutions below

0
Sanket Wankhede On

I simply add This =>

localItem: string | null;

and finally it's working!

1
alezhu On

add '?' after type localItem:string?;