Skip to content

Commit f177345

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 #4443
1 parent 536add3 commit f177345

27 files changed

+50
-60
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.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Renderer2} from '@angular/core';
1+
import {Component} from '@angular/core';
22
import {FocusOriginMonitor} from '@angular/material';
33

44

@@ -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
@@ -92,7 +92,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
9292
private _manuallyFloatingPlaceholder = false;
9393

9494
/** View -> model callback called when value changes */
95-
_onChange = (value: any) => {};
95+
_onChange: (value: any) => void = () => {};
9696

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

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('MdAutocomplete', () => {
7272
}},
7373
{provide: Dir, useFactory: () => ({value: dir})},
7474
{provide: ScrollDispatcher, useFactory: () => {
75-
return {scrolled: (delay: number, callback: () => any) => {
75+
return {scrolled: (_delay: number, callback: () => any) => {
7676
return scrolledSubject.asObservable().subscribe(callback);
7777
}};
7878
}}

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) => void = () => {};
818+
onCheckboxChange: (event?: MdCheckboxChange) => void = () => {};
819819
}
820820

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

src/lib/checkbox/checkbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class MdCheckbox extends _MdCheckboxMixinBase
186186

187187
private _indeterminate: boolean = false;
188188

189-
private _controlValueAccessorChangeFn: (value: any) => void = (value) => {};
189+
private _controlValueAccessorChangeFn: (value: any) => void = () => {};
190190

191191
/** Reference to the focused state ripple. */
192192
private _focusRipple: RippleRef;

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) => void = () => {};
242+
chipDeselect: (index?: number) => void = () => {};
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) => void = () => {};
139+
chipDestroy: (event?: MdChipEvent) => void = () => {};
140+
chipSelect: (event?: MdChipEvent) => void = () => {};
141+
chipDeselect: (event?: MdChipEvent) => void = () => {};
149142
}
150143

151144
@Component({

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ function getHeaderCells(tableElement: Element): Element[] {
275275
}
276276

277277
const tableCustomMatchers: jasmine.CustomMatcherFactories = {
278-
toMatchTableContent: function(util, customEqualityTesters) {
278+
toMatchTableContent: () => {
279279
return {
280280
compare: function (tableElement: Element, expectedTableContent: any[]) {
281281
const missedExpectations = [];

0 commit comments

Comments
 (0)