Thanks for sharing the complete solutions!
There are functional alternatives to forEach, for and other array operations.
For example, this code:
let itemsAsList: string[] = [];
itemsAsSet.forEach((v) => {
if (v !== undefined && v !== null) itemsAsList.push(v);
});
return itemsAsList;
can be written as:
let itemsAsList = itemsAsSet.filter((v) =>
v !== undefined && v !== null
));
return itemsAsList;