From cd968863c25c09ffc83c51e7e673b1059d4f9501 Mon Sep 17 00:00:00 2001 From: Klemen Oslaj Date: Sat, 21 Mar 2020 06:07:29 +0100 Subject: [PATCH] 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 --- src/cdk/coercion/array.ts | 2 ++ tools/public_api_guard/cdk/coercion.d.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/src/cdk/coercion/array.ts b/src/cdk/coercion/array.ts index 6ab9c7eb1d4b..d76caf60ccde 100644 --- a/src/cdk/coercion/array.ts +++ b/src/cdk/coercion/array.ts @@ -7,6 +7,8 @@ */ /** Wraps the provided value in an array, unless the provided value is an array. */ +export function coerceArray(value: T | T[]): T[]; +export function coerceArray(value: T | readonly T[]): readonly T[]; export function coerceArray(value: T | T[]): T[] { return Array.isArray(value) ? value : [value]; } diff --git a/tools/public_api_guard/cdk/coercion.d.ts b/tools/public_api_guard/cdk/coercion.d.ts index 1cf0d8e786ec..72cc86a324bb 100644 --- a/tools/public_api_guard/cdk/coercion.d.ts +++ b/tools/public_api_guard/cdk/coercion.d.ts @@ -3,6 +3,7 @@ export declare function _isNumberValue(value: any): boolean; export declare type BooleanInput = string | boolean | null | undefined; export declare function coerceArray(value: T | T[]): T[]; +export declare function coerceArray(value: T | readonly T[]): readonly T[]; export declare function coerceBooleanProperty(value: any): boolean;