```typescript
export function parseCsvLine(line: string): string[] {
    if (typeof line !== 'string') throw Error('Expected string input');
    let fields = [];
    let field = '';
    let isQuotedField = false;
    for (const c of line) {
        switch (c) {
            case '"': isQuotedField = !isQuotedField; break;
            case ',': if (!isQuotedField) { fields.push(field); field = ''; } else field += c; break;
            default: field += c; break;
        }
    }
    if (isQuotedField) throw Error('Unexpected end of line in quoted field');
    fields.push(field);  // Push last field
    return fields;
}
```