To start, you must establish a generic type using a combination of conditional and recursive logic.
type MySeparatedType<T,K> =
T extends `${infer R1},${infer R2}` ?
R1 extends K ?
`${R1},${MySeparatedType<R2,K>}` : never : T extends K ?
T : never;
Next, apply this type as the argument in a utility function.
const MySeparatedFunction = <T,K extends ActionType = ActionType>(value: MySeparatedType<T,K>) => value
You can now utilize this function to accomplish your desired outcome.
Examples:
const result1 = MySeparatedFunction("ItemA")
//result1 is of type "ItemA"
const result2 = MySeparatedFunction("ItemB,ItemA,ItemC")
//result2 is of type "ItemB,ItemA,ItemC"
const result3 = MySeparatedFunction("ItemC$ItemA")
// result3 is of type never