Skip to content

Commit b763107

Browse files
committed
fix(cdk/coercion): add the support for readonly array coercion
Fixes a type definition of coerceArray so that it accepts both mutable and immutable arrays. Fixes #18806
1 parent 807498d commit b763107

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/cdk/coercion/array.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88

99
/** Wraps the provided value in an array, unless the provided value is an array. */
10+
export function coerceArray<T>(value: T | T[]): T[];
11+
export function coerceArray<T>(value: T | readonly T[]): readonly T[];
1012
export function coerceArray<T>(value: T | T[]): T[] {
1113
return Array.isArray(value) ? value : [value];
1214
}

tools/public_api_guard/cdk/coercion.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export declare function _isNumberValue(value: any): boolean;
33
export declare type BooleanInput = string | boolean | null | undefined;
44

55
export declare function coerceArray<T>(value: T | T[]): T[];
6+
export declare function coerceArray<T>(value: T | readonly T[]): readonly T[];
67

78
export declare function coerceBooleanProperty(value: any): boolean;
89

0 commit comments

Comments
 (0)