```ts
export function runLengthEncode(input: string): string {
  if (typeof input !== 'string') {
    throw new Error("Argument must be a string");
  }

  let result = '';
  const uniqueChars = Array.from(new Set(input));
  for (const char of uniqueChars) {
    const count = input.split(char).length - 1;
    result += `${char}${count}`;
  }
  return result;
}
```