tslint how to disable error “someVariable is declared but its value is never read ”

后端 未结 8 759
盖世英雄少女心
盖世英雄少女心 2021-02-02 05:05

I\'m using tslint, and got the error.

\'myVariable\' is declared but its value is never read.

I went to the website that documents the rules

相关标签:
8条回答
  • 2021-02-02 05:39

    Another way to avoid this is to create a get-method for every variable you have, like this:

    get variablename():variabletype{return this.variablename;}
    
    0 讨论(0)
  • 2021-02-02 05:43

    Fist question:

    Edit the file:tsconfig.json, adding/modifying key "noUnusedLocals": false.

    You'll need to restart the server.

    Second question:

    If it is a tslint error; VS Code shows, in the error message, the rule that's been applied.

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

    The prefer-const rule in this case.

    0 讨论(0)
提交回复
热议问题