tslint / codelyzer / ng lint error: “for (… in …) statements must be filtered with an if statement”

前端 未结 6 625
广开言路
广开言路 2020-12-07 09:33

Lint error message:

src/app/detail/edit/edit.component.ts[111, 5]: for (... in ...) statements must be filtered with an if statement

6条回答
  •  猫巷女王i
    2020-12-07 09:40

    If the behavior of for(... in ...) is acceptable/necessary for your purposes, you can tell tslint to allow it.

    in tslint.json, add this to the "rules" section.

    "forin": false
    

    Otherwise, @Maxxx has the right idea with

    for (const field of Object.keys(this.formErrors)) {
    

提交回复
热议问题