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
{{ message }}
Repository navigation
Unused underscore variables not being ignored by lint rules #19614
changed the title [-]Unused underscore variables note being ignored by lint rules[/-][+]Unused underscore variables not being ignored by lint rules[/+]on Oct 31, 2017
My use case for this is array destructing. I have a function that returns a "tuple" (an array like [int, string]) and in some cases I would like to ignore one of the elements i.e. const [_foo, bar] = func() but keep the tuple-like semantics. const bar = func()[1] no longer communicates that this is a tuple.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Activity
[-]Unused underscore variables note being ignored by lint rules[/-][+]Unused underscore variables not being ignored by lint rules[/+]chmeyers commentedon Oct 31, 2017
Originally noticed this on this variable:
https://github.com/yebrahim/datalab/blob/52ab35257d8c338ba10dfbf631fa756e603e37c7/sources/web/datalab/polymer/components/auth-panel/auth-panel.ts#L22
Let me see if I can make a self-contained repro.
chmeyers commentedon Oct 31, 2017
Repro:
class TestClass {
private _shouldBeIgnored: boolean;
_someFunction() {
this._shouldBeIgnored = true;
}
}
tsc --noUnusedLocals test.ts
(Works in 2.5.3, fails on 2.6.1 (and latest nightly))
chmeyers commentedon Oct 31, 2017
In our particular case these variables are read by the html page.
nikklassen commentedon Nov 1, 2017
My use case for this is array destructing. I have a function that returns a "tuple" (an array like
[int, string]) and in some cases I would like to ignore one of the elements i.e.const [_foo, bar] = func()but keep the tuple-like semantics.const bar = func()[1]no longer communicates that this is a tuple.aluanhaddad commentedon Nov 2, 2017
Nik Klassen (@nikklassen) you can use a leading
,as inpetemcwilliams commentedon Nov 8, 2017
This warning
Would be more useful than the one I was getting in version 2.6.1
Because it is a new check I was searching for quite a while to figure this out, seeing the variable was being used (written to) in the ts.
typescript-bot commentedon Nov 22, 2017
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.