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

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

        if (char === '"') {
            if (!inQuotes || line[i + 1] === '"') {
                currentField += char;
                if (i + 1 && line[i + 1] === '"') {
                    i++; // Skip the next character as it's a doubled quote
                }
                inQuotes = !inQuotes;
            } else {
                throw new Error('Unclosed quoted field');
            }
        } else if (char === ',' && !inQuotes) {
            fields.push(currentField);
            currentField = '';
        } else {
            currentField += char;
        }
    }

    fields.push(currentField);

    return fields;
}
```