Skip to content

Commit 8faa683

Browse files
committed
Replace switch with falsyness checks
1 parent 26370e0 commit 8faa683

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/material/datepicker/calendar.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,9 @@ export class MatCalendar<D> implements AfterContentInit, AfterViewChecked, OnDes
418418

419419
/** Returns the component instance that corresponds to the current calendar view. */
420420
private _getCurrentViewComponent(): MatMonthView<D> | MatYearView<D> | MatMultiYearView<D> {
421-
// The return type must be a union to ensure that the Closure compiler does not optimize the
422-
// calls to _init(). See https://github.com/angular/components/issues/22996.
423-
switch (this.currentView) {
424-
case 'month':
425-
return this.monthView;
426-
case 'year':
427-
return this.yearView;
428-
case 'multi-year':
429-
return this.multiYearView;
430-
}
421+
// The return type is explicitly written as a union to ensure that the Closure compiler does
422+
// not optimize the calls to _init(). Without the explict return type, TypeScript narrows it
423+
// to only the first component type. See https://github.com/angular/components/issues/22996.
424+
return this.monthView || this.yearView || this.multiYearView;
431425
}
432426
}

0 commit comments

Comments
 (0)