diff --git a/src/core/types/array.js b/src/core/types/array.js index 653247038923e..faba24f7978ba 100644 --- a/src/core/types/array.js +++ b/src/core/types/array.js @@ -34,14 +34,20 @@ export const {isArray} = Array; /** * If the specified argument is an array, it's returned as is. If it's a * single item, the array containing this item is created and returned. - * @param {!Array|T} arrayOrSingleItem - * @return {!Array} + * + * The double-template pattern here solves a bug where CC can be passed a value + * with declared type {string|!Array} and return a value with a type of + * {!Array>}. + * + * @param {!Array|S} arrayOrSingleItem + * @return {!Array|!Array} + * @template S * @template T */ export function arrayOrSingleItemToArray(arrayOrSingleItem) { return isArray(arrayOrSingleItem) ? /** @type {!Array} */ (arrayOrSingleItem) - : [arrayOrSingleItem]; + : [/** @type {!S} */ (arrayOrSingleItem)]; } /**