0

I have a situation, demo code below:

       const callFnWithArgs = (callback: (a: string, b: number) => void) =>
       async (a: string, b: number): Promise<void> => {
          try { 
               await callback(a,b)
              }
        catch(e){
            console.log(e)
        }

The code works fine, but I have ESLint unused vars property setup in the project. I receive error that a and b are unused-vars in line 1.

Any solution for this? Function signature changes are welcome.

Note:

  1. I do not wish to disable/bypass the unused vars property globally or here.
  2. I do not wish to use 'any'
  3. I do not wish to remove the type so that it would infer 'any'
Ritik Banger
  • 2,107
  • 5
  • 25

3 Answers3

1

see https://typescript-eslint.io/rules/no-unused-vars/

How to Use

// .eslintrc.cjs
module.exports = {
  "rules": {
    // Note: you must disable the base rule as it can report incorrect errors
    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": "warn"
  }
};
Dimava
  • 7,654
  • 1
  • 9
  • 24
1

try checking the following discussions ESLint - Configuring "no-unused-vars" for TypeScript

there might be some eslint configuration issues

Oxy
  • 19
  • 2
1

You need to use @typescript-eslint/no-unused-vars instead of no-unused-vars.

If you need to override a config, here's how to do it !

"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn"
Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
  • But why? Can you please elaborate on the difference between no-unused-vars vs @typescript-eslint/no-unused-vars. Are not both the same? – Ritik Banger Nov 06 '22 at 07:03