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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/demo-app/dialog/dialog-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class DialogDemo {
// Possible useful example for the open and closeAll events.
// Adding a class to the body if a dialog opens and
// removing it after all open dialogs are closed
dialog.afterOpen.subscribe((ref: MdDialogRef<any>) => {
dialog.afterOpen.subscribe(() => {
if (!doc.body.classList.contains('no-scroll')) {
doc.body.classList.add('no-scroll');
}
Expand Down
4 changes: 2 additions & 2 deletions src/demo-app/style/style-demo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Renderer2} from '@angular/core';
import {Component} from '@angular/core';
import {FocusOriginMonitor} from '@angular/material';


Expand All @@ -9,5 +9,5 @@ import {FocusOriginMonitor} from '@angular/material';
styleUrls: ['style-demo.css'],
})
export class StyleDemo {
constructor(public renderer: Renderer2, public fom: FocusOriginMonitor) {}
constructor(public fom: FocusOriginMonitor) {}
}
2 changes: 1 addition & 1 deletion src/lib/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
private _manuallyFloatingPlaceholder = false;

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

/** View -> model callback called when autocomplete has been touched */
_onTouched = () => {};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/autocomplete/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,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

return scrolledSubject.asObservable().subscribe(callback);
}};
}}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/button-toggle/button-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor
* The method to be called in order to update ngModel.
* Now `ngModel` binding is not supported in multiple selection mode.
*/
private _controlValueAccessorChangeFn: (value: any) => void = (value) => {};
private _controlValueAccessorChangeFn: (value: any) => void = () => {};

/** onTouch function registered via registerOnTouch (ControlValueAccessor). */
onTouched: () => any = () => {};
Expand Down
4 changes: 2 additions & 2 deletions src/lib/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,8 @@ class SingleCheckbox {
checkboxColor: string = 'primary';
checkboxValue: string = 'single_checkbox';

onCheckboxClick(event: Event) {}
onCheckboxChange(event: MdCheckboxChange) {}
onCheckboxClick: (event?: Event) => void = () => {};
onCheckboxChange: (event?: MdCheckboxChange) => void = () => {};
}

/** Simple component for testing an MdCheckbox with ngModel. */
Expand Down
2 changes: 1 addition & 1 deletion src/lib/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class MdCheckbox extends _MdCheckboxMixinBase

private _indeterminate: boolean = false;

private _controlValueAccessorChangeFn: (value: any) => void = (value) => {};
private _controlValueAccessorChangeFn: (value: any) => void = () => {};

/** Reference to the focused state ripple. */
private _focusRipple: RippleRef;
Expand Down
9 changes: 3 additions & 6 deletions src/lib/chips/chip-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,8 @@ describe('MdChipList', () => {
class StaticChipList {
name: string = 'Test';
selectable: boolean = true;
remove: Number;
remove: number;

chipSelect(index: Number) {
}

chipDeselect(index: Number) {
}
chipSelect: (index?: number) => void = () => {};
chipDeselect: (index?: number) => void = () => {};
}
15 changes: 4 additions & 11 deletions src/lib/chips/chip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,10 @@ class SingleChip {
selected: boolean = false;
shouldShow: boolean = true;

chipFocus(event: MdChipEvent) {
}

chipDestroy(event: MdChipEvent) {
}

chipSelect(event: MdChipEvent) {
}

chipDeselect(event: MdChipEvent) {
}
chipFocus: (event?: MdChipEvent) => void = () => {};
chipDestroy: (event?: MdChipEvent) => void = () => {};
chipSelect: (event?: MdChipEvent) => void = () => {};
chipDeselect: (event?: MdChipEvent) => void = () => {};
}

@Component({
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/data-table/data-table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function getHeaderCells(tableElement: Element): Element[] {
}

const tableCustomMatchers: jasmine.CustomMatcherFactories = {
toMatchTableContent: function(util, customEqualityTesters) {
toMatchTableContent: () => {
return {
compare: function (tableElement: Element, expectedTableContent: any[]) {
const missedExpectations = [];
Expand Down
8 changes: 6 additions & 2 deletions src/lib/core/datetime/native-date-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = Array(length);
for (let i = 0; i < length; i++) {
valuesArray[i] = valueFunction(i);
}
return valuesArray;
}


Expand Down Expand Up @@ -123,7 +127,7 @@ export class NativeDateAdapter extends DateAdapter<Date> {
return new Date();
}

parse(value: any, parseFormat: Object): Date | null {
parse(value: any): Date | null {
// We have no way using the native JS Date to set the parse format or locale, so we ignore these
// parameters.
let timestamp = typeof value == 'number' ? value : Date.parse(value);
Expand Down
3 changes: 1 addition & 2 deletions src/lib/core/overlay/scroll/close-scroll-strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
OverlayState,
OverlayRef,
OverlayModule,
ScrollStrategy,
ScrollDispatcher,
} from '../../core';

Expand All @@ -23,7 +22,7 @@ describe('CloseScrollStrategy', () => {
imports: [OverlayModule, PortalModule, OverlayTestModule],
providers: [
{provide: ScrollDispatcher, useFactory: () => {
return {scrolled: (delay: number, callback: () => any) => {
return {scrolled: (_delay: number, callback: () => any) => {
return scrolledSubject.asObservable().subscribe(callback);
}};
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
OverlayState,
OverlayRef,
OverlayModule,
ScrollStrategy,
ScrollDispatcher,
} from '../../core';

Expand All @@ -23,7 +22,7 @@ describe('RepositionScrollStrategy', () => {
imports: [OverlayModule, PortalModule, OverlayTestModule],
providers: [
{provide: ScrollDispatcher, useFactory: () => {
return {scrolled: (delay: number, callback: () => any) => {
return {scrolled: (_delay: number, callback: () => any) => {
return scrolledSubject.asObservable().subscribe(callback);
}};
}}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/overlay/scroll/scroll-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

if (this.scrollableContainsElement(scrollable, elementRef)) {
scrollingContainers.push(scrollable);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/style/focus-origin-monitor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ class PlainButton {
template: `<button cdkMonitorElementFocus (cdkFocusChange)="focusChanged($event)"></button>`
})
class ButtonWithFocusClasses {
focusChanged(origin: FocusOrigin) {}
focusChanged(_origin: FocusOrigin) {}
}


Expand Down
3 changes: 1 addition & 2 deletions src/lib/core/testing/jasmine-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* Collection of useful custom jasmine matchers for tests.
*/
export const customMatchers: jasmine.CustomMatcherFactories = {
toBeRole: function(util: jasmine.MatchersUtil,
customEqualityTesters: jasmine.CustomEqualityTester[]) {
toBeRole: () => {
return {
compare: function (element: Element, expectedRole: string) {
const result: jasmine.CustomMatcherResult = {pass: false};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/testing/type-in-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {dispatchFakeEvent} from './dispatch-events';
* @param value Value to be set on the input.
* @param element Element onto which to set the value.
*/
export function typeInElement(value: string, element: HTMLInputElement, autoFocus = true) {
export function typeInElement(value: string, element: HTMLInputElement) {
element.focus();
element.value = value;
dispatchFakeEvent(element, 'input');
Expand Down
2 changes: 1 addition & 1 deletion src/lib/datepicker/datepicker-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class MdDatepickerInput<D> implements AfterContentInit, ControlValueAcces

_onTouched = () => {};

private _cvaOnChange = (value: any) => {};
private _cvaOnChange: (value: any) => void = () => {};

private _validatorOnChange = () => {};

Expand Down
14 changes: 7 additions & 7 deletions src/lib/grid-list/tile-styler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {TileCoordinator} from './tile-coordinator';
* Tile Coordinator.
* @docs-private
*/
export class TileStyler {
export abstract class TileStyler {
_gutterSize: string;
_rows: number = 0;
_rowspan: number = 0;
Expand Down Expand Up @@ -122,11 +122,12 @@ export class TileStyler {
* This method will be implemented by each type of TileStyler.
* @docs-private
*/
setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number, gutterWidth: number) {}
abstract setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number,
gutterWidth: number);

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

setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number,
gutterWidth: number): void {
setRowStyles(tile: MdGridTile, rowIndex: number): void {
tile._setStyle('top', this.getTilePosition(this.fixedRowHeight, rowIndex));
tile._setStyle('height', calc(this.getTileSize(this.fixedRowHeight, tile.rowspan)));
}
Expand Down Expand Up @@ -215,8 +215,7 @@ export class RatioTileStyler extends TileStyler {
*/
export class FitTileStyler extends TileStyler {

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

Expand All @@ -229,6 +228,7 @@ export class FitTileStyler extends TileStyler {
tile._setStyle('top', this.getTilePosition(baseTileHeight, rowIndex));
tile._setStyle('height', calc(this.getTileSize(baseTileHeight, tile.rowspan)));
}

}


Expand Down
4 changes: 2 additions & 2 deletions src/lib/icon/icon-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class MdIconRegistry {
.filter(iconSetConfig => !iconSetConfig.svgElement)
.map(iconSetConfig =>
this._loadSvgIconSetFromConfig(iconSetConfig)
.catch((err: any, caught: Observable<SVGElement>): Observable<SVGElement> => {
.catch((err: any): Observable<SVGElement> => {
let url =
this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);

Expand All @@ -263,7 +263,7 @@ export class MdIconRegistry {
// Fetch all the icon set URLs. When the requests complete, every IconSet should have a
// cached SVG element (unless the request failed), and we can check again for the icon.
return Observable.forkJoin(iconSetFetchRequests)
.map((ignoredResults: any) => {
.map(() => {
const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
if (!foundIcon) {
throw getMdIconNameNotFoundError(name);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/radio/radio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('MdRadio', () => {
expect(radioInstances[0].checked).toBe(false);

let spies = radioInstances
.map((value, index) => jasmine.createSpy(`onChangeSpy ${index}`));
.map((radio, index) => jasmine.createSpy(`onChangeSpy ${index} for ${radio.name}`));

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

Expand Down
2 changes: 1 addition & 1 deletion src/lib/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
private _disabled: boolean = false;

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

/**
* onTouch function registered via registerOnTouch (ControlValueAccessor).
Expand Down
8 changes: 4 additions & 4 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('MdSelect', () => {
}},
{provide: Dir, useFactory: () => dir = { value: 'ltr' }},
{provide: ScrollDispatcher, useFactory: () => {
return {scrolled: (delay: number, callback: () => any) => {
return {scrolled: (_delay: number, callback: () => any) => {
return scrolledSubject.asObservable().subscribe(callback);
}};
}}
Expand Down Expand Up @@ -2324,9 +2324,9 @@ class SelectInitWithoutOptions {
class CustomSelectAccessor implements ControlValueAccessor {
@ViewChild(MdSelect) select: MdSelect;

writeValue(val: any): void {}
registerOnChange(fn: (val: any) => void): void {}
registerOnTouched(fn: Function): void {}
writeValue: (value?: any) => void = () => {};
registerOnChange: (changeFn?: (value: any) => void) => void = () => {};
registerOnTouched: (touchedFn?: () => void) => void = () => {};
}

@Component({
Expand Down
2 changes: 1 addition & 1 deletion src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
_selectedValueWidth: number;

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

/** View -> model callback called when select has been touched */
_onTouched = () => {};
Expand Down
6 changes: 2 additions & 4 deletions src/lib/slide-toggle/slide-toggle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,10 +685,8 @@ class SlideToggleTestApp {
lastEvent: MdSlideToggleChange;
labelPosition: string;

onSlideClick(event: Event) {}
onSlideChange(event: MdSlideToggleChange) {
this.lastEvent = event;
}
onSlideClick: (event?: Event) => void = () => {};
onSlideChange = (event: MdSlideToggleChange) => this.lastEvent = event;
}


Expand Down
2 changes: 1 addition & 1 deletion src/lib/snack-bar/snack-bar-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class MdSnackBarContainer extends BasePortalHost implements OnDestroy {
}

/** Attach a template portal as content to this snack bar container. */
attachTemplatePortal(portal: TemplatePortal): Map<string, any> {
attachTemplatePortal(): Map<string, any> {
throw new Error('Not yet implemented');
}

Expand Down
1 change: 1 addition & 0 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"experimentalDecorators": true,
"module": "es2015",
"moduleResolution": "node",
"noUnusedParameters": true,
"outDir": "../dist/packages/all",
"sourceMap": true,
"inlineSources": true,
Expand Down