```ts
export function parseCsvLine(line: string): string[] {
  const fields: string[] = [];
  let currentField = '';
  let insideQuotes = false;

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

    if (char === '"') {
      if (i + 1 < line.length && line[i + 1] === '"') {
        // Double quote inside a quoted field means one literal quote character
        currentField += '"';
        i++; // Skip the next character as it's part of the escape sequence
      } else {
        // Toggle quotes state
        insideQuotes = !insideQuotes;
      }
    } else if (char === ',' && !insideQuotes) {
      // End of a field
      fields.push(currentField);
      currentField = '';
    } else {
      // Add character to the current field
      currentField += char;
    }
  }

  // If we finish processing and are still inside quotes, it's an error
  if (insideQuotes) {
    throw new Error('Quoted field is never closed');
  }

  // Push the last field if there is one
  fields.push(currentField);

  return fields;
}
```