Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(cdk/coercion): add the support for readonly array coercion (#18807)
Fixes a type definition of coerceArray so that it accepts both mutable and
immutable arrays.

Fixes #18806
  • Loading branch information
klemenoslaj committed Mar 21, 2020
1 parent 4ea7157 commit cd96886
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cdk/coercion/array.ts
Expand Up @@ -7,6 +7,8 @@
*/

/** Wraps the provided value in an array, unless the provided value is an array. */
export function coerceArray<T>(value: T | T[]): T[];
export function coerceArray<T>(value: T | readonly T[]): readonly T[];
export function coerceArray<T>(value: T | T[]): T[] {
return Array.isArray(value) ? value : [value];
}
1 change: 1 addition & 0 deletions tools/public_api_guard/cdk/coercion.d.ts
Expand Up @@ -3,6 +3,7 @@ export declare function _isNumberValue(value: any): boolean;
export declare type BooleanInput = string | boolean | null | undefined;

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

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

Expand Down

0 comments on commit cd96886

Please sign in to comment.