-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix: make material work with noUnusedParameters #4946
fix: make material work with noUnusedParameters #4946
Conversation
@@ -67,7 +67,7 @@ describe('MdAutocomplete', () => { | |||
}}, | |||
{provide: Dir, useFactory: () => ({value: dir})}, | |||
{provide: ScrollDispatcher, useFactory: () => { | |||
return {scrolled: (delay: number, callback: () => any) => { | |||
return {scrolled: (_delay: number, callback: () => any) => { |
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.
Why does this need an underscore? I'd prefer not to use _
for function arguments; is TS not smart enough to know that you've included an argument so that you can have access to a subsequent one?
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 unfortunately it's smart enough do detect this
@@ -105,7 +105,7 @@ export class ScrollDispatcher { | |||
getScrollContainers(elementRef: ElementRef): Scrollable[] { | |||
const scrollingContainers: Scrollable[] = []; | |||
|
|||
this.scrollableReferences.forEach((subscription: Subscription, scrollable: Scrollable) => { | |||
this.scrollableReferences.forEach((_subscription: Subscription, scrollable: Scrollable) => { |
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.
Change this to this.scrollableReferences.keys().forEach(...)
?
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.
Unfortunately there is no forEach()
method for iterators. And if we want to use iterators here we need to enable down-leveling of those (read here and this requires a runtime shim for non-arrays.
src/lib/checkbox/checkbox.spec.ts
Outdated
onCheckboxClick(event: Event) {} | ||
onCheckboxChange(event: MdCheckboxChange) {} | ||
onCheckboxClick(_event: Event) {} | ||
onCheckboxChange(_event: MdCheckboxChange) {} |
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.
Should change these to be properties instead of methods since they're reassigned anyway, e.g.
onCheckboxClick: (Event?) => void = () => {};
(here and elsewhere that follows this pattern)
@@ -31,7 +31,7 @@ const DEFAULT_DAY_OF_WEEK_NAMES = { | |||
|
|||
/** Creates an array and fills it with values. */ | |||
function range<T>(length: number, valueFunction: (index: number) => T): T[] { | |||
return Array.apply(null, Array(length)).map((v: undefined, i: number) => valueFunction(i)); | |||
return Array.apply(null, Array(length)).map((_v: undefined, i: number) => valueFunction(i)); |
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.
We could eliminate this case by switching to a for
loop... (which is faster anyway)
@@ -129,7 +129,7 @@ export class FocusOriginMonitor { | |||
* @param renderer The renderer to use to invoke the focus method on the element. | |||
* @param origin The focus origin. | |||
*/ | |||
focusVia(element: HTMLElement, renderer: Renderer2, origin: FocusOrigin): void { | |||
focusVia(element: HTMLElement, origin: FocusOrigin): void { |
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.
This one is a breaking change that will need Google to be updated, so we should do it in a separate PR
(I checked, there are people using it)
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.
Agreed, prefixing with an underscore should work for now.
src/lib/radio/radio.spec.ts
Outdated
@@ -143,7 +143,7 @@ describe('MdRadio', () => { | |||
expect(radioInstances[0].checked).toBe(false); | |||
|
|||
let spies = radioInstances | |||
.map((value, index) => jasmine.createSpy(`onChangeSpy ${index}`)); | |||
.map((_value, index) => jasmine.createSpy(`onChangeSpy ${index}`)); |
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.
Could add the value
into the spy name so that it's used.
@jelbourn Addressed your feedback. Expect the one with the Iterator. |
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 aside from one comment
Can add merge-ready when done
@@ -31,7 +31,11 @@ const DEFAULT_DAY_OF_WEEK_NAMES = { | |||
|
|||
/** Creates an array and fills it with values. */ | |||
function range<T>(length: number, valueFunction: (index: number) => T): T[] { | |||
return Array.apply(null, Array(length)).map((v: undefined, i: number) => valueFunction(i)); | |||
const valuesArray = []; |
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.
const valuesArray = Array(length);
Better to initialize it to the right length
4aee7f8
to
8774c91
Compare
* Recently Angular core fixed their `noUnusedParameters` warnings in angular/angular#15532 * When using Angular with Material and the users has `noUnusedParameters` enabled the library will be checked and will throw. Fixes angular#4443
8774c91
to
f177345
Compare
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. |
noUnusedParameters
warnings in Unused Parameters in Ng Factory code angular#15532 (this one is still left - Unused $event parameters in AOT generated code angular#17131)noUnusedParameters
enabled the library will be checked and will throw right now.Note: I don't plan to add the
noUnusedParameters
to any build tsconfig files yet, because it would make the watching & live-reloading extremely bad. ThenoUnusedParameters
should / can be tested on the CI in a follow-up.Fixes #4443