Reproduction
Use StackBlitz to reproduce your issue: https://stackblitz.com/fork/components-issue
Steps to reproduce:
- Open: https://stackblitz.com/edit/components-issue-axn4qw?embed=1&file=src/app/example-component.ts&view=editor
- TS compile error appears
Expected Behavior
What behavior were you expecting to see?
coerceArray should preserve the readonly array.
Actual Behavior
What behavior did you actually see?
An error:
Argument of type 'readonly number[]' is not assignable to parameter of type 'number | number[]'.
The type 'readonly number[]' is 'readonly' and cannot be assigned to the mutable type 'number[]'.
Environment
dependencies from stackblitz
- Angular: 9.0.2
- CDK/Material: 9.1.0
My thoughts
Type definition is:
export declare function coerceArray<T>(value: T | T[]): T[];
I think it should b:
export declare function coerceArray<T>(value: T | readonly T[]): T[];
This way it would accept both mutable and readonly arrays.
Reproduction
Use StackBlitz to reproduce your issue: https://stackblitz.com/fork/components-issue
Steps to reproduce:
Expected Behavior
What behavior were you expecting to see?
coerceArrayshould preserve the readonly array.Actual Behavior
What behavior did you actually see?
An error:
Environment
dependencies from stackblitz
My thoughts
Type definition is:
I think it should b:
This way it would accept both mutable and readonly arrays.