What is causing VSCode to ignore _ prefixed arguments like _arg? ts(6133)

22 hours ago 3
ARTICLE AD BOX

I turned off eslint and this is what I get in the IDE: (Only row is used.)

function argument cell is dimmed, but _column is not

When I hover each of those arguments, I get this:

'cell' is declared but its value is never read.ts(6133) 'ev' is declared but its value is never read.ts(6133) // nothing for _cell // nothing for _ev

When I add and enable configuration for noUnusedParameters in tsconfig.json, I get this:
function argument cell has squiggles, but _column does not

And the very same ts(6133) warnings as above, nothing on _x.

👉 How can I make it so that

unused variables are rendered with squiggles and a warning unless that variable is prefixed with _, e.g. _ev, in that case, no squiggles and warning any unused variable is dimmed, even those prefixed

My reasoning for rule 3 is simple: An unused variable is still unused and I want to see it quickly in IDE, even if I choose to ignore it by naming it _x. The thing is that in all the variables, it is much easier to spot a dimmed variable than a prefixed variable. And secondly, sometimes I need underscored variables to avoid shadowing, e.g.

const table = //... some global variable { // the example could be better, but you get my point someCallback: (_ev, _value, _table) => { const value = clamp(0, _value, 100) return _table.rows.map(row => row + value) // _ev is unused // _value is deliberately named with underscore // _table, because table exists in the higher scope } }

But alll variables are rendered opaque:
function argument ev is unused and dimmed, _value is used and opaque

This is better, but it would produce squiggles when noUnusedParameters is enabled.
function argument _ev is unused, _value is used, but both are opaque

It is definitely caused by typescript, because this is what I get when TS Server is turned off (restarting). all arguments are opaque

Read Entire Article