Accept unknown and produce a clean string[]. If input is a single string, split it by commas. If it is an array, keep items that are strings. Trim spaces.
This is a common pattern when normalizing user input.
function toList(x: unknown) {
if (typeof x === "string") return x.split(",");
return Array.isArray(x) ? x : [];
}
Create a function that normalizes names into an array of trimmed strings.