-
Notifications
You must be signed in to change notification settings - Fork 6.8k
build: stricter unused variable checking #6633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: stricter unused variable checking #6633
Conversation
src/lib/paginator/paginator.spec.ts
Outdated
@@ -281,7 +281,7 @@ class MdPaginatorApp { | |||
|
|||
@ViewChild(MdPaginator) mdPaginator: MdPaginator; | |||
|
|||
constructor(private _elementRef: ElementRef) { } | |||
constructor() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Currently only variables that don't start with an underscore will be checked by TSLint. This doesn't make sense, because variables get prefixed with an underscore to indicate that they are not part of the public API, but still need to be public in favor of AOT compilation for example. This means that those properties are having the public modifier set (explicitly or automatically) and therefore won't be treated as unused anyway. **TL;DR**: With this change, prefixed variables will be checked by the `no-unused-variable` TSLint rule and those which are marked as `private` and are unused will be catched by TSLint.
a534d55
to
775b0f8
Compare
@@ -89,6 +89,7 @@ export class StartWithBrand { private _; } | |||
export class DebounceTimeBrand { private _; } | |||
export class AuditTimeBrand { private _; } | |||
export class TakeUntilBrand { private _; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be ok with having these properties be public. They're not a part of any API or generated JS anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't mind either. I just changed it
Edit: Actually it looks like making the property public causes TypeScript to complain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The brand properties actually must be private
, otherwise they are structurally identical to each other
336b331
to
775b0f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Currently only variables that don't start with an underscore will be checked by TSLint.
This doesn't make sense, because variables get prefixed with an underscore to indicate that they are not part of the public API, but still need to be public in favor of AOT compilation for example. This means that those properties are having the public modifier set (explicitly or automatically) and therefore won't be treated as unused anyway.
TL;DR: With this change, prefixed variables will be checked by the
no-unused-variable
TSLint rule and those which are marked asprivate
and are unused will be catched by TSLint.