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

    for (const char of line) {
        if (escapeNext) {
            field += char === '""' ? '"' : char;
            escapeNext = false;
        } else if (char === '"') {
            inQuotes = !inQuotes;
        } else if (char === ',' && !inQuotes) {
            result.push(field.trim());
            field = '';
        } else {
            field += char;
            if (char === '\\') {
                escapeNext = true;
            }
        }
    }

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

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