Skip to content

docs(material/paginator): add explicit type for better formatting in docs #20608

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
Sep 22, 2020
Merged
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
21 changes: 11 additions & 10 deletions src/material/paginator/paginator-intl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,21 @@ export class MatPaginatorIntl {
lastPageLabel: string = 'Last page';

/** A label for the range of items within the current page and the length of the whole list. */
getRangeLabel = (page: number, pageSize: number, length: number) => {
if (length == 0 || pageSize == 0) { return `0 of ${length}`; }
getRangeLabel: (page: number, pageSize: number, length: number) => string =
(page: number, pageSize: number, length: number) => {
if (length == 0 || pageSize == 0) { return `0 of ${length}`; }

length = Math.max(length, 0);
length = Math.max(length, 0);

const startIndex = page * pageSize;
const startIndex = page * pageSize;

// If the start index exceeds the list length, do not try and fix the end index to the end.
const endIndex = startIndex < length ?
Math.min(startIndex + pageSize, length) :
startIndex + pageSize;
// If the start index exceeds the list length, do not try and fix the end index to the end.
const endIndex = startIndex < length ?
Math.min(startIndex + pageSize, length) :
startIndex + pageSize;

return `${startIndex + 1} – ${endIndex} of ${length}`;
}
return `${startIndex + 1} – ${endIndex} of ${length}`;
}
}

/** @docs-private */
Expand Down