Skip to content

Commit 3e85d2a

Browse files
committed
fix: make material work with noUnusedParameters
* 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
1 parent cebb516 commit 3e85d2a

30 files changed

+56
-69
lines changed

src/demo-app/dialog/dialog-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class DialogDemo {
3838
// Possible useful example for the open and closeAll events.
3939
// Adding a class to the body if a dialog opens and
4040
// removing it after all open dialogs are closed
41-
dialog.afterOpen.subscribe((ref: MdDialogRef<any>) => {
41+
dialog.afterOpen.subscribe(() => {
4242
if (!doc.body.classList.contains('no-scroll')) {
4343
doc.body.classList.add('no-scroll');
4444
}

src/demo-app/style/style-demo.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<button #b class="demo-focusable" cdkMonitorElementFocus>focus me!</button>
22
<button (click)="b.focus()">focus programmatically</button>
33

4-
<button (click)="fom.focusVia(b, renderer, 'mouse')">focusVia: mouse</button>
5-
<button (click)="fom.focusVia(b, renderer, 'touch')">focusVia: touch</button>
6-
<button (click)="fom.focusVia(b, renderer, 'keyboard')">focusVia: keyboard</button>
7-
<button (click)="fom.focusVia(b, renderer, 'program')">focusVia: program</button>
4+
<button (click)="fom.focusVia(b, 'mouse')">focusVia: mouse</button>
5+
<button (click)="fom.focusVia(b, 'touch')">focusVia: touch</button>
6+
<button (click)="fom.focusVia(b, 'keyboard')">focusVia: keyboard</button>
7+
<button (click)="fom.focusVia(b, 'program')">focusVia: program</button>
88

99
<div>Active classes: {{b.classList}}</div>
1010

src/demo-app/style/style-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ import {FocusOriginMonitor} from '@angular/material';
99
styleUrls: ['style-demo.css'],
1010
})
1111
export class StyleDemo {
12-
constructor(public renderer: Renderer2, public fom: FocusOriginMonitor) {}
12+
constructor(public fom: FocusOriginMonitor) {}
1313
}

src/lib/autocomplete/autocomplete-trigger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
8383
private _manuallyFloatingPlaceholder = false;
8484

8585
/** View -> model callback called when value changes */
86-
_onChange = (value: any) => {};
86+
_onChange: (value: any) => void = () => {};
8787

8888
/** View -> model callback called when autocomplete has been touched */
8989
_onTouched = () => {};

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('MdAutocomplete', () => {
6767
}},
6868
{provide: Dir, useFactory: () => ({value: dir})},
6969
{provide: ScrollDispatcher, useFactory: () => {
70-
return {scrolled: (delay: number, callback: () => any) => {
70+
return {scrolled: (_delay: number, callback: () => any) => {
7171
return scrolledSubject.asObservable().subscribe(callback);
7272
}};
7373
}}

src/lib/button-toggle/button-toggle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor
8080
* The method to be called in order to update ngModel.
8181
* Now `ngModel` binding is not supported in multiple selection mode.
8282
*/
83-
private _controlValueAccessorChangeFn: (value: any) => void = (value) => {};
83+
private _controlValueAccessorChangeFn: (value: any) => void = () => {};
8484

8585
/** onTouch function registered via registerOnTouch (ControlValueAccessor). */
8686
onTouched: () => any = () => {};

src/lib/checkbox/checkbox.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,8 @@ class SingleCheckbox {
814814
checkboxColor: string = 'primary';
815815
checkboxValue: string = 'single_checkbox';
816816

817-
onCheckboxClick(event: Event) {}
818-
onCheckboxChange(event: MdCheckboxChange) {}
817+
onCheckboxClick(_event: Event) {}
818+
onCheckboxChange(_event: MdCheckboxChange) {}
819819
}
820820

821821
/** Simple component for testing an MdCheckbox with ngModel. */

src/lib/checkbox/checkbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export class MdCheckbox extends _MdCheckboxMixinBase
185185

186186
private _color: string;
187187

188-
private _controlValueAccessorChangeFn: (value: any) => void = (value) => {};
188+
private _controlValueAccessorChangeFn: (value: any) => void = () => {};
189189

190190
/** Reference to the focused state ripple. */
191191
private _focusRipple: RippleRef;
@@ -393,7 +393,7 @@ export class MdCheckbox extends _MdCheckboxMixinBase
393393

394394
/** Focuses the checkbox. */
395395
focus(): void {
396-
this._focusOriginMonitor.focusVia(this._inputElement.nativeElement, this._renderer, 'keyboard');
396+
this._focusOriginMonitor.focusVia(this._inputElement.nativeElement, 'keyboard');
397397
}
398398

399399
_onInteractionEvent(event: Event) {

src/lib/chips/chip-list.spec.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,8 @@ describe('MdChipList', () => {
236236
class StaticChipList {
237237
name: string = 'Test';
238238
selectable: boolean = true;
239-
remove: Number;
239+
remove: number;
240240

241-
chipSelect(index: Number) {
242-
}
243-
244-
chipDeselect(index: Number) {
245-
}
241+
chipSelect(_index: number) {}
242+
chipDeselect(_index: number) {}
246243
}

src/lib/chips/chip.spec.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,10 @@ class SingleChip {
135135
selected: boolean = false;
136136
shouldShow: boolean = true;
137137

138-
chipFocus(event: MdChipEvent) {
139-
}
140-
141-
chipDestroy(event: MdChipEvent) {
142-
}
143-
144-
chipSelect(event: MdChipEvent) {
145-
}
146-
147-
chipDeselect(event: MdChipEvent) {
148-
}
138+
chipFocus(_event: MdChipEvent) {}
139+
chipDestroy(_event: MdChipEvent) {}
140+
chipSelect(_event: MdChipEvent) {}
141+
chipDeselect(_event: MdChipEvent) {}
149142
}
150143

151144
@Component({

src/lib/core/data-table/data-table.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing';
22
import {Component, ViewChild} from '@angular/core';
33
import {CdkTable} from './data-table';
44
import {CollectionViewer, DataSource} from './data-source';
5-
import {CommonModule} from '@angular/common';
65
import {Observable} from 'rxjs/Observable';
76
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
87
import {customMatchers} from '../testing/jasmine-matchers';
@@ -213,7 +212,7 @@ function getHeaderCells(tableElement: Element): Element[] {
213212
}
214213

215214
const tableCustomMatchers: jasmine.CustomMatcherFactories = {
216-
toMatchTableContent: function(util, customEqualityTesters) {
215+
toMatchTableContent: () => {
217216
return {
218217
compare: function (tableElement: Element, expectedTableContent: any[]) {
219218
const missedExpectations = [];

src/lib/core/datetime/native-date-adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const DEFAULT_DAY_OF_WEEK_NAMES = {
3131

3232
/** Creates an array and fills it with values. */
3333
function range<T>(length: number, valueFunction: (index: number) => T): T[] {
34-
return Array.apply(null, Array(length)).map((v: undefined, i: number) => valueFunction(i));
34+
return Array.apply(null, Array(length)).map((_v: undefined, i: number) => valueFunction(i));
3535
}
3636

3737

@@ -123,7 +123,7 @@ export class NativeDateAdapter extends DateAdapter<Date> {
123123
return new Date();
124124
}
125125

126-
parse(value: any, parseFormat: Object): Date | null {
126+
parse(value: any): Date | null {
127127
// We have no way using the native JS Date to set the parse format or locale, so we ignore these
128128
// parameters.
129129
let timestamp = typeof value == 'number' ? value : Date.parse(value);

src/lib/core/overlay/scroll/close-scroll-strategy.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
OverlayState,
99
OverlayRef,
1010
OverlayModule,
11-
ScrollStrategy,
1211
ScrollDispatcher,
1312
CloseScrollStrategy,
1413
} from '../../core';
@@ -24,7 +23,7 @@ describe('CloseScrollStrategy', () => {
2423
imports: [OverlayModule, PortalModule, OverlayTestModule],
2524
providers: [
2625
{provide: ScrollDispatcher, useFactory: () => {
27-
return {scrolled: (delay: number, callback: () => any) => {
26+
return {scrolled: (_delay: number, callback: () => any) => {
2827
return scrolledSubject.asObservable().subscribe(callback);
2928
}};
3029
}}

src/lib/core/overlay/scroll/reposition-scroll-strategy.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
OverlayState,
99
OverlayRef,
1010
OverlayModule,
11-
ScrollStrategy,
1211
ScrollDispatcher,
1312
RepositionScrollStrategy,
1413
} from '../../core';
@@ -24,7 +23,7 @@ describe('RepositionScrollStrategy', () => {
2423
imports: [OverlayModule, PortalModule, OverlayTestModule],
2524
providers: [
2625
{provide: ScrollDispatcher, useFactory: () => {
27-
return {scrolled: (delay: number, callback: () => any) => {
26+
return {scrolled: (_delay: number, callback: () => any) => {
2827
return scrolledSubject.asObservable().subscribe(callback);
2928
}};
3029
}}

src/lib/core/overlay/scroll/scroll-dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class ScrollDispatcher {
105105
getScrollContainers(elementRef: ElementRef): Scrollable[] {
106106
const scrollingContainers: Scrollable[] = [];
107107

108-
this.scrollableReferences.forEach((subscription: Subscription, scrollable: Scrollable) => {
108+
this.scrollableReferences.forEach((_subscription: Subscription, scrollable: Scrollable) => {
109109
if (this.scrollableContainsElement(scrollable, elementRef)) {
110110
scrollingContainers.push(scrollable);
111111
}

src/lib/core/style/focus-origin-monitor.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe('FocusOriginMonitor', () => {
131131
}));
132132

133133
it('focusVia keyboard should simulate keyboard focus', async(() => {
134-
focusOriginMonitor.focusVia(buttonElement, buttonRenderer, 'keyboard');
134+
focusOriginMonitor.focusVia(buttonElement, 'keyboard');
135135
fixture.detectChanges();
136136

137137
setTimeout(() => {
@@ -148,7 +148,7 @@ describe('FocusOriginMonitor', () => {
148148
}));
149149

150150
it('focusVia mouse should simulate mouse focus', async(() => {
151-
focusOriginMonitor.focusVia(buttonElement, buttonRenderer, 'mouse');
151+
focusOriginMonitor.focusVia(buttonElement, 'mouse');
152152
fixture.detectChanges();
153153

154154
setTimeout(() => {
@@ -165,7 +165,7 @@ describe('FocusOriginMonitor', () => {
165165
}));
166166

167167
it('focusVia mouse should simulate mouse focus', async(() => {
168-
focusOriginMonitor.focusVia(buttonElement, buttonRenderer, 'touch');
168+
focusOriginMonitor.focusVia(buttonElement, 'touch');
169169
fixture.detectChanges();
170170

171171
setTimeout(() => {
@@ -182,7 +182,7 @@ describe('FocusOriginMonitor', () => {
182182
}));
183183

184184
it('focusVia program should simulate programmatic focus', async(() => {
185-
focusOriginMonitor.focusVia(buttonElement, buttonRenderer, 'program');
185+
focusOriginMonitor.focusVia(buttonElement, 'program');
186186
fixture.detectChanges();
187187

188188
setTimeout(() => {
@@ -464,7 +464,7 @@ class PlainButton {
464464
template: `<button cdkMonitorElementFocus (cdkFocusChange)="focusChanged($event)"></button>`
465465
})
466466
class ButtonWithFocusClasses {
467-
focusChanged(origin: FocusOrigin) {}
467+
focusChanged(_origin: FocusOrigin) {}
468468
}
469469

470470

src/lib/core/style/focus-origin-monitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class FocusOriginMonitor {
129129
* @param renderer The renderer to use to invoke the focus method on the element.
130130
* @param origin The focus origin.
131131
*/
132-
focusVia(element: HTMLElement, renderer: Renderer2, origin: FocusOrigin): void {
132+
focusVia(element: HTMLElement, origin: FocusOrigin): void {
133133
this._setOriginForCurrentEventQueue(origin);
134134
element.focus();
135135
}

src/lib/core/testing/jasmine-matchers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
* Collection of useful custom jasmine matchers for tests.
33
*/
44
export const customMatchers: jasmine.CustomMatcherFactories = {
5-
toBeRole: function(util: jasmine.MatchersUtil,
6-
customEqualityTesters: jasmine.CustomEqualityTester[]) {
5+
toBeRole: () => {
76
return {
87
compare: function (element: Element, expectedRole: string) {
98
const result: jasmine.CustomMatcherResult = {pass: false};

src/lib/core/testing/type-in-element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {dispatchFakeEvent} from './dispatch-events';
66
* @param value Value to be set on the input.
77
* @param element Element onto which to set the value.
88
*/
9-
export function typeInElement(value: string, element: HTMLInputElement, autoFocus = true) {
9+
export function typeInElement(value: string, element: HTMLInputElement) {
1010
element.focus();
1111
element.value = value;
1212
dispatchFakeEvent(element, 'input');

src/lib/datepicker/datepicker-input.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class MdDatepickerInput<D> implements AfterContentInit, ControlValueAcces
121121

122122
_onTouched = () => {};
123123

124-
private _cvaOnChange = (value: any) => {};
124+
private _cvaOnChange: (value: any) => void = () => {};
125125

126126
private _validatorOnChange = () => {};
127127

src/lib/grid-list/tile-styler.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {TileCoordinator} from './tile-coordinator';
66
* Tile Coordinator.
77
* @docs-private
88
*/
9-
export class TileStyler {
9+
export abstract class TileStyler {
1010
_gutterSize: string;
1111
_rows: number = 0;
1212
_rowspan: number = 0;
@@ -122,11 +122,12 @@ export class TileStyler {
122122
* This method will be implemented by each type of TileStyler.
123123
* @docs-private
124124
*/
125-
setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number, gutterWidth: number) {}
125+
abstract setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number,
126+
gutterWidth: number);
126127

127128
/**
128129
* Calculates the computed height and returns the correct style property to set.
129-
* This method will be implemented by each type of TileStyler.
130+
* This method can be implemented by each type of TileStyler.
130131
* @docs-private
131132
*/
132133
getComputedHeight(): [string, string] { return null; }
@@ -147,8 +148,7 @@ export class FixedTileStyler extends TileStyler {
147148
this.fixedRowHeight = normalizeUnits(this.fixedRowHeight);
148149
}
149150

150-
setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number,
151-
gutterWidth: number): void {
151+
setRowStyles(tile: MdGridTile, rowIndex: number): void {
152152
tile._setStyle('top', this.getTilePosition(this.fixedRowHeight, rowIndex));
153153
tile._setStyle('height', calc(this.getTileSize(this.fixedRowHeight, tile.rowspan)));
154154
}
@@ -215,8 +215,7 @@ export class RatioTileStyler extends TileStyler {
215215
*/
216216
export class FitTileStyler extends TileStyler {
217217

218-
setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number,
219-
gutterWidth: number): void {
218+
setRowStyles(tile: MdGridTile, rowIndex: number): void {
220219
// Percent of the available vertical space that one row takes up.
221220
let percentHeightPerTile = 100 / this._rowspan;
222221

@@ -229,6 +228,7 @@ export class FitTileStyler extends TileStyler {
229228
tile._setStyle('top', this.getTilePosition(baseTileHeight, rowIndex));
230229
tile._setStyle('height', calc(this.getTileSize(baseTileHeight, tile.rowspan)));
231230
}
231+
232232
}
233233

234234

src/lib/icon/icon-registry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export class MdIconRegistry {
245245
.filter(iconSetConfig => !iconSetConfig.svgElement)
246246
.map(iconSetConfig =>
247247
this._loadSvgIconSetFromConfig(iconSetConfig)
248-
.catch((err: any, caught: Observable<SVGElement>): Observable<SVGElement> => {
248+
.catch((err: any): Observable<SVGElement> => {
249249
let url =
250250
this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);
251251

@@ -263,7 +263,7 @@ export class MdIconRegistry {
263263
// Fetch all the icon set URLs. When the requests complete, every IconSet should have a
264264
// cached SVG element (unless the request failed), and we can check again for the icon.
265265
return Observable.forkJoin(iconSetFetchRequests)
266-
.map((ignoredResults: any) => {
266+
.map(() => {
267267
const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
268268
if (!foundIcon) {
269269
throw getMdIconNameNotFoundError(name);

src/lib/radio/radio.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ describe('MdRadio', () => {
143143
expect(radioInstances[0].checked).toBe(false);
144144

145145
let spies = radioInstances
146-
.map((value, index) => jasmine.createSpy(`onChangeSpy ${index}`));
146+
.map((_value, index) => jasmine.createSpy(`onChangeSpy ${index}`));
147147

148148
spies.forEach((spy, index) => radioInstances[index].change.subscribe(spy));
149149

src/lib/radio/radio.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
9595
private _disabled: boolean = false;
9696

9797
/** The method to be called in order to update ngModel */
98-
_controlValueAccessorChangeFn: (value: any) => void = (value) => {};
98+
_controlValueAccessorChangeFn: (value: any) => void = () => {};
9999

100100
/**
101101
* onTouch function registered via registerOnTouch (ControlValueAccessor).
@@ -462,7 +462,7 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy {
462462

463463
/** Focuses the radio button. */
464464
focus(): void {
465-
this._focusOriginMonitor.focusVia(this._inputElement.nativeElement, this._renderer, 'keyboard');
465+
this._focusOriginMonitor.focusVia(this._inputElement.nativeElement, 'keyboard');
466466
}
467467

468468
/**

0 commit comments

Comments
 (0)