Skip to content

Commit 5216d38

Browse files
authored
chore(typescript): uniformly access all index signature with index access. (#15206)
This is a strictness check that we are going to enforce in g3 internal typescript, to aid with optimization. Generally it is also syntactically a good idea to have visual indication when a type is accessed through an index signature vs not.
1 parent 3ae6eb2 commit 5216d38

File tree

8 files changed

+19
-17
lines changed

8 files changed

+19
-17
lines changed

src/cdk/drag-drop/directives/drag.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
250250
}
251251

252252
ngOnChanges(changes: SimpleChanges) {
253-
const rootSelectorChange = changes.rootElementSelector;
253+
const rootSelectorChange = changes['rootElementSelector'];
254254

255255
// We don't have to react to the first change since it's being
256256
// handled in `ngAfterViewInit` where it needs to be deferred.

src/lib/datepicker/calendar-body.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ export class MatCalendarBody implements OnChanges {
105105
}
106106

107107
ngOnChanges(changes: SimpleChanges) {
108-
const columnChanges = changes.numCols;
108+
const columnChanges = changes['numCols'];
109109
const {rows, numCols} = this;
110110

111-
if (changes.rows || columnChanges) {
111+
if (changes['rows'] || columnChanges) {
112112
this._firstRowOffset = rows && rows.length && rows[0].length ? numCols - rows[0].length : 0;
113113
}
114114

115-
if (changes.cellAspectRatio || columnChanges || !this._cellPadding) {
115+
if (changes['cellAspectRatio'] || columnChanges || !this._cellPadding) {
116116
this._cellPadding = `${50 * this.cellAspectRatio / numCols}%`;
117117
}
118118

src/lib/datepicker/calendar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ export class MatCalendar<D> implements AfterContentInit, AfterViewChecked, OnDes
318318
}
319319

320320
ngOnChanges(changes: SimpleChanges) {
321-
const change = changes.minDate || changes.maxDate || changes.dateFilter;
321+
const change =
322+
changes['minDate'] || changes['maxDate'] || changes['dateFilter'];
322323

323324
if (change && !change.firstChange) {
324325
const view = this._getCurrentViewComponent();

src/lib/datepicker/datepicker-toggle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class MatDatepickerToggle<D> implements AfterContentInit, OnChanges, OnDe
9292
}
9393

9494
ngOnChanges(changes: SimpleChanges) {
95-
if (changes.datepicker) {
95+
if (changes['datepicker']) {
9696
this._watchStateChanges();
9797
}
9898
}

src/lib/dialog/dialog-content-directives.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export class MatDialogClose implements OnInit, OnChanges {
7676
}
7777

7878
ngOnChanges(changes: SimpleChanges) {
79-
const proxiedChange = changes._matDialogClose || changes._matDialogCloseResult;
79+
const proxiedChange =
80+
changes['_matDialogClose'] || changes['_matDialogCloseResult'];
8081

8182
if (proxiedChange) {
8283
this.dialogResult = proxiedChange.currentValue;

src/lib/expansion/expansion-panel-header.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,18 @@ export class MatExpansionPanelHeader implements OnDestroy, FocusableOption {
7777
private _changeDetectorRef: ChangeDetectorRef,
7878
@Inject(MAT_EXPANSION_PANEL_DEFAULT_OPTIONS) @Optional()
7979
defaultOptions?: MatExpansionPanelDefaultOptions) {
80-
8180
const accordionHideToggleChange = panel.accordion ?
82-
panel.accordion._stateChanges.pipe(filter(changes => !!changes.hideToggle)) : EMPTY;
81+
panel.accordion._stateChanges.pipe(
82+
filter(changes => !!changes['hideToggle'])) :
83+
EMPTY;
8384

8485
// Since the toggle state depends on an @Input on the panel, we
8586
// need to subscribe and trigger change detection manually.
86-
this._parentChangeSubscription = merge(
87-
panel.opened,
88-
panel.closed,
89-
accordionHideToggleChange,
90-
panel._inputChanges.pipe(filter(changes => !!(changes.hideToggle || changes.disabled)))
91-
)
87+
this._parentChangeSubscription =
88+
merge(
89+
panel.opened, panel.closed, accordionHideToggleChange,
90+
panel._inputChanges.pipe(filter(
91+
changes => !!(changes['hideToggle'] || changes['disabled']))))
9292
.subscribe(() => this._changeDetectorRef.markForCheck());
9393

9494
// Avoids focus being lost if the panel contained the focused element and was closed.

src/lib/icon/icon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export class MatIcon extends _MatIconMixinBase implements OnChanges, OnInit, Aft
223223

224224
ngOnChanges(changes: SimpleChanges) {
225225
// Only update the inline SVG icon if the inputs changed, to avoid unnecessary DOM operations.
226-
if (changes.svgIcon) {
226+
if (changes['svgIcon']) {
227227
if (this.svgIcon) {
228228
const [namespace, iconName] = this._splitIconName(this.svgIcon);
229229

src/lib/select/select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
552552
ngOnChanges(changes: SimpleChanges) {
553553
// Updating the disabled state is handled by `mixinDisabled`, but we need to additionally let
554554
// the parent form field know to run change detection when the disabled state changes.
555-
if (changes.disabled) {
555+
if (changes['disabled']) {
556556
this.stateChanges.next();
557557
}
558558
}

0 commit comments

Comments
 (0)