How to stop 'was declared but never used' error detector


#1

Hello guys,

As you guys aware, now we get ‘was declared but never used’ error when something is declared but not used in a project.
I think this error didn’t exist in previous version of angular… but the problem is this error detects working code as a problem when the code is not immediately in use.

Is there any way to deactivate this error detection? I don’t think this error detector has any significant role in my current project.

Thanks,


#2

do you have an example, I don’t get what you mean

to answer your question, I didn’t try, but there is maybe a tsconfig.json to set to ignore these warnings?


#3

like

"noUnusedLocals": true,
"noUnusedParameters": true,

see https://github.com/palantir/tslint/issues/2451


#4

I’m troubled with this topic.

But this is not really an error at all. Without that code, search feature will not run.
So I see the error detector is not helping in this case.

Thanks, I will check the tsconfig.json file!


#5

No worries, let us know if it works

But otherwise I would say, I a variable is declared but never use and that you double check the code and notice that you don’t it then, just delete it :wink:


#6

Thanks a lot!

I changed this configuration in tsconfig.json from true to false:

"noUnusedParameters": false,

and now typescript stopped throwing “was declared but never used” error.

In my current project, these unused parameters are necessary and even if they’re errors, they’re not supposed to stop the whole app from starting.