```ts
/**
 * Parses a single CSV line into its fields, handling quoted fields and escaped quotes.
 * @param line - A single line of CSV text.
 * @returns An array of field values.
 * @throws Error if a quoted field is never closed.
 */
export function parseCsvLine(line: string): string[] {
  const fields: string[] = [];
  let currentField = '';
  let inQuotes = false;
  let i = 0;

  while (i < line.length) {
    const char = line[i];

    if (!inQuotes) {
      if (char === '"') {
        inQuotes = true;
      } else if (char === ',') {
        fields.push(currentField);
        currentField = '';
      } else {
        currentField += char;
      }
    } else {
      // Inside quotes
      if (char === '"') {
        // Check for doubled quote
        if (i + 1 < line.length && line[i + 1] === '"') {
          currentField += '"';
          i++; // Skip the next quote
        } else {
          // End of quoted section
          inQuotes = false;
        }
      } else {
        currentField += char;
      }
    }

    i++;
  }

  // Push the last field
  fields.push(currentField);

  // Check for unclosed quote
  if (inQuotes) {
    throw new Error('Unclosed quoted field');
  }

  return fields;
}
```