Fransisco Wijaya
Fransisco Wijaya

Reputation: 397

TSLint tells my identifier is never reassigned, but it's changeable somehow

What should I do? The method is work either I use let or const.

As you can see at the image below, the variable is binded with my input element and used multiple times due to iteration.

(Does two-way binding is described as const/let when its value change / you can change its value?).

This is the full method

And here is the linter say:

Identifier 'electronic' is never reassigned; use 'const' instead of 'let'. (prefer-const)

Upvotes: 3

Views: 5474

Answers (1)

iSkriD
iSkriD

Reputation: 118

There are 2 issues in understanding the technologies:

  1. TSLint has no idea about your 2 way binding, so it inform you about the missing reassignment
  2. Your variable exist only inside of this for-loop, so using const there would be completely fine since you did not plan to modify the value during one iteration

Upvotes: 4

Related Questions