You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow underscore prefix to bypass noUnusedLocals warning
This PR continues [Allow leading underscore for
types...](#58884),
taking into account feedback from https://github.com/microsoft/TypeScript/pull/58884/files#r1643108204.
The initial commit on this PR is original work by @a-tarasyuk. The second
commit enhances the test suite and reverts the change to checker.ts to
get a new baseline on the test suite for easier comparison with the
changes. The third commit changes checker.ts to allow any unused local if
it is prefixed with an underscore. This has the effect of newly allowing
the following unused declarations:
```ts
// Variables were previously allowed only in destructuring and for-loops
const _unusedVar = 2;
let _unusedLet = 4;
var _unusedVar2 = 6;
function _unusedFunc() { }
const _unusedArrow = () => { };
class _UnusedClass { }
interface _UnusedInterface { }
type _UnusedType = string;
enum _UnusedEnum { A }
namespace _UnusedNamespace { ... }
```
As far as I can tell, enum members and properties are not checked in the
checkUnusedLocalsAndParameters function, and we do not need to special-case
them.
Closes#58561
0 commit comments