facebook

invalid error reported using let in a for of loop

  1. CodeMix & Angular IDE
  2.  > 
  3. Getting Help
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #611975 Reply

    Arthur Clifford
    Participant

    Writing a for of loop in TypeScript such as:

    for( let item in someArray) {

    }

    CodeMix has a red light bulb next to the line the for( let item … line that says:
    Fix identifier “item” is never reassigned use “const” instead of ‘let”

    This is factually incorrect as the whole point of the for loop is to reassign the value of item through iterations of someArray.

    I can of course disable that for the line, but we shouldn’t have to.

    #611978 Reply

    Brian Fernandes
    Moderator

    Arthur,

    This error is coming from ESLint’s prefer-const rule. I don’t think this is on by default.

    Do you have an ESLint configuration file in your project, like .eslintrc.js? The idea would be to find the file and disable the rule within there. It may be something that’s explicitly turned on, or on by default if your ESLint configuration extends some other configuration – in which case you can add an explicit rule to disable it. Of course, if you don’t care for ESLint at all, you can disable it entirely, though I don’t think that’s what you want.

    Hope this helps, do let us know if you need further assistance.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: invalid error reported using let in a for of loop

You must be logged in to post in the forum log in