Skip to content
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

Merged

Conversation

devversion
Copy link
Member

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. The noUnusedParameters should / can be tested on the CI in a follow-up.

Fixes #4443

@devversion devversion requested a review from jelbourn June 3, 2017 09:56
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 3, 2017
@@ -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) => {
Copy link
Member

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?

Copy link
Member Author

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) => {
Copy link
Member

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(...) ?

Copy link
Member Author

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.

onCheckboxClick(event: Event) {}
onCheckboxChange(event: MdCheckboxChange) {}
onCheckboxClick(_event: Event) {}
onCheckboxChange(_event: MdCheckboxChange) {}
Copy link
Member

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));
Copy link
Member

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 {
Copy link
Member

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)

Copy link
Member Author

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.

@@ -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}`));
Copy link
Member

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.

@devversion
Copy link
Member Author

@jelbourn Addressed your feedback. Expect the one with the Iterator.

Copy link
Member

@jelbourn jelbourn left a 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 = [];
Copy link
Member

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

@devversion devversion force-pushed the fix/material-with-unused-locals branch 2 times, most recently from 4aee7f8 to 8774c91 Compare June 8, 2017 15:20
* 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
@devversion devversion force-pushed the fix/material-with-unused-locals branch from 8774c91 to f177345 Compare June 8, 2017 16:19
@devversion devversion added the action: merge The PR is ready for merge by the caretaker label Jun 8, 2017
@andrewseguin andrewseguin merged commit 4b98f21 into angular:master Jun 8, 2017
@devversion devversion deleted the fix/material-with-unused-locals branch June 8, 2017 21:33
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ng cli build --prod fails when activating noUnusedParameters in tsconfig.json
4 participants