Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript error:- Property 'forEach' does not exist on type 'string'

whenever i used forEach() i got this error in terminal

[ts] Property 'forEach' does not exist on type 'string'.

My application works in browser properly. Everything works properly but i don't want such errors in terminal.

I used below code for it. Please suggest me what i missing.

 job.forEach(function(state) {
        if((totalcarer['userId']+"")===state.rNo)
        {
          cjobState = state.cJobstatus;
        }
      });
like image 813
Harish Mahajan Avatar asked Jun 02 '26 22:06

Harish Mahajan


1 Answers

arrays: string[];
arrayString: string;

See the diff between? one is array and another is string.

arrays.forEach(...) // valid.
arrayString.forEach(...) //invalid.
like image 141
Smit Avatar answered Jun 05 '26 02:06

Smit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!