-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels