You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
ERROR: test-for-loop.ts[1, 7]: expected variable-declaration: 'split' to have a typedef
ERROR: test-for-loop.ts[2, 10]: expected variable-declaration: 'i' to have a typedef
Expected behavior
The typedef rule should ignore variables declared within for loop declarations.
Looking at the source, typedefRule.ts line 176, there is condition written:
TypeScript actually doesn't allow a type annotation on the LHS of for-in or for-of loops, so the typedef rule must not check for one there. Since a regular for loop can contain an arbitrary initializer, it makes sense to check for a type declaration there.
I think the real issue here is that the typedef rule isn't great and often leads to overly-verbose code. See #711 for somewhat related discussion. What'd be best here may be to let typedef ignore simple declarations like let i = 0 all together.
Bug Report
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
Expected behavior
The typedef rule should ignore variables declared within for loop declarations.
Looking at the source, typedefRule.ts line 176, there is condition written:
I think it should also include basic
ForStatement
kind:In this case it does not falesly reports on 'i' to have typedef.
Any specific reason it is left out?
The text was updated successfully, but these errors were encountered: