diff --git a/js/src/common/utils/ItemList.ts b/js/src/common/utils/ItemList.ts index f00b54f511..a65e07f3df 100644 --- a/js/src/common/utils/ItemList.ts +++ b/js/src/common/utils/ItemList.ts @@ -200,9 +200,16 @@ export default class ItemList { * This **does not** preserve the original types of primitives and proxies * all content values to make `itemName` accessible on them. * + * **NOTE:** If your ItemList holds primitive types (such as numbers, booleans + * or strings), these will be converted to their object counterparts if you do + * not provide `true` to this function. + * * **NOTE:** Modifying any objects in the final array may also update the * content of the original ItemList. * + * @param keepPrimitives Converts item content to objects and sets the + * `itemName` property on them. + * * @see https://github.com/flarum/core/issues/3030 */ toArray(keepPrimitives?: false): (T & { itemName: string })[]; @@ -215,25 +222,12 @@ export default class ItemList { * * **NOTE:** Modifying any objects in the final array may also update the * content of the original ItemList. - */ - toArray(keepPrimitives: true): (T extends object ? T & Readonly<{ itemName: string }> : T)[]; - - /** - * Convert the list into an array of item content arranged by priority. - * - * Each item's content will be assigned an `itemName` property equal to the - * item's unique key. - * - * **NOTE:** If your ItemList holds primitive types (such as numbers, booleans - * or strings), these will be converted to their object counterparts if you do - * not provide `true` to this function. - * - * **NOTE:** Modifying any objects in the final array may also update the - * content of the original ItemList. * * @param keepPrimitives Converts item content to objects and sets the * `itemName` property on them. */ + toArray(keepPrimitives: true): (T extends object ? T & Readonly<{ itemName: string }> : T)[]; + toArray(keepPrimitives: boolean = false): T[] | (T & Readonly<{ itemName: string }>)[] { const items: Item[] = Object.keys(this._items).map((key, i) => { const item = this._items[key];