```ts
export function parseCsvLine(line: string): string[] {
  const result: string[] = [];
  let field = '';
  let inQuotes = false;

  for (let i = 0; i <= line.length; i++) {
    const char = line[i];
    if (char === '"') {
      if (!inQuotes) {
        inQuotes = true;
      } else if (i + 1 < line.length && line[i + 1] === '"') {
        field += char;
        i++;
      } else {
        throw new Error('Unquoted double quote found');
      }
    } else if (char === ',' || i === line.length) {
      result.push(field.trim());
      field = '';
      inQuotes = false;
    } else {
      field += char;
    }
  }

  return result;
}
```