```ts
export function stripComments(source: string): string {
  let result = '';
  let inString = false;
  let inBlockComment = false;

  for (let i = 0; i < source.length; i++) {
    if (source[i] === '"' && (i === 0 || source[i - 1] !== '\\')) {
      inString = !inString;
    } else if (!inString) {
      if (source[i] === '/' && source[i + 1] === '*') {
        i++;
        inBlockComment = true;
      } else if (source[i] === '*' && source[i + 1] === '/') {
        i++;
        inBlockComment = false;
      } else if (!inBlockComment) {
        result += source[i];
      }
    }
  }

  if (inString) {
    throw new Error("Unterminated string literal");
  }
  if (inBlockComment) {
    throw new Error("Unterminated block comment");
  }

  return result;
}
```