```ts
export function parseCsvLine(line: string): string[] {
  if (typeof line !== 'string') {
    throw new Error('Input must be a string');
  }

  const fields: string[] = [];
  let currentField = '';
  let inQuote = false;
  let escaped = false;

  for (let i = 0; i < line.length; i++) {
    const char = line[i];

    if (inQuote) {
      if (char === '"') {
        if (escaped) {
          currentField += '"';
          escaped = false;
        } else {
          inQuote = false;
        }
      } else {
        currentField += char;
      }
    } else if (char === ',') {
      if (!inQuote && !escaped) {
        fields.push(currentField);
        currentField = '';
      } else {
        throw new Error('Comma found after closing quote');
      }
    } else if (char === '"') {
      if (i > 0 && line[i - 1] !== ',') {
        throw new Error('Quote inside unquoted field');
      }
      inQuote = true;
      escaped = false;
    } else {
      currentField += char;
      escaped = false;
    }
  }

  if (inQuote) {
    throw new Error('Unterminated quoted field');
  }

  fields.push(currentField);

  return fields;
}
```