Skip to content

refactor(multiple): add non-null assertions first and last #23958

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

Merged
merged 1 commit into from
Nov 15, 2021
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/cdk/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
*/
_getNodeDef(data: T, i: number): CdkTreeNodeDef<T> {
if (this._nodeDefs.length === 1) {
return this._nodeDefs.first;
return this._nodeDefs.first!;
}

const nodeDef =
Expand Down
4 changes: 2 additions & 2 deletions src/material-experimental/mdc-slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ export class MatSlider

/** Gets the slider thumb input of the given thumb position. */
_getInput(thumbPosition: Thumb): MatSliderThumb {
return thumbPosition === Thumb.END ? this._inputs.last : this._inputs.first;
return thumbPosition === Thumb.END ? this._inputs.last! : this._inputs.first!;
}

/** Gets the slider thumb HTML input element of the given thumb position. */
Expand All @@ -856,7 +856,7 @@ export class MatSlider
}

_getThumb(thumbPosition: Thumb): MatSliderVisualThumb {
return thumbPosition === Thumb.END ? this._thumbs.last : this._thumbs.first;
return thumbPosition === Thumb.END ? this._thumbs.last! : this._thumbs.first!;
}

/** Gets the slider thumb HTML element of the given thumb position. */
Expand Down
2 changes: 1 addition & 1 deletion src/material/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export class _MatMenuBase
// Move focus to the menu panel so keyboard events like Escape still work. Also this will
// give _some_ feedback to screen readers.
if (!manager.activeItem && this._directDescendantItems.length) {
let element = this._directDescendantItems.first._getHostElement().parentElement;
let element = this._directDescendantItems.first!._getHostElement().parentElement;

// Because the `mat-menu` is at the DOM insertion point, not inside the overlay, we don't
// have a nice way of getting a hold of the menu panel. We can't use a `ViewChild` either
Expand Down