```ts

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

  let encoded = '';
  for (let i = 0; i < input.length; i++) {
    const count = 1;
    while (i + count < input.length && input[i] === input[i + count]) {
      count++;
    }
    encoded += `${input[i]}${count}`;
  }

  return encoded;
}
```