Skip to content

bug(MatPaginator): pageSizeOptions are required to be mutable Array, ReadonlyArray fails #24050

Closed
@max-vogler

Description

@max-vogler

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

MatPaginator requires pageSizeOptions to be a mutable array. Passing in a ReadonlyArray fails.

Reproduction

Steps to reproduce:

@Component({
  selector: 'example-component',
  template: '<mat-paginator [pageSizeOptions]="pageSizeOptions"></mat-paginator>',
})
export class ExampleComponent {
 pageSizeOptions: ReadonlyArray<number> = [10, 20];
}

https://stackblitz.com/edit/components-issue-rvmtli?file=src/app/example-component.ts

Expected Behavior

I am unaware that MatPaginator would mutate the passed in Array. Passing in a ReadonlyArray should work.

Actual Behavior

Throws

The type 'readonly number[]' is 'readonly' and cannot be assigned to the mutable type 'number[]'.

Environment

  • Angular: ^12.2.9
  • CDK/Material: ^12.2.9
  • TypeScript: ^3.7.5
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: material/paginator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions