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

  for (let i = 0; i < line.length; i++) {
    if (line[i] === '"') {
      if (i > 0 && line[i - 1] === '"' && !inQuotes) {
        field += '"';
      } else {
        inQuotes = !inQuotes;
      }
    } else if (line[i] === ',' && !inQuotes) {
      result.push(field.trim());
      field = '';
    } else {
      field += line[i];
    }
  }

  if (inQuotes) {
    throw new Error('Quoted field never closed');
  }

  result.push(field.trim());
  return result;
}
```