import React, { forwardRef } from 'react'; type CommonProps = { className?: string; invalid?: boolean; }; type InputBased = CommonProps & Omit, 'as'> & { as?: 'input'; }; type TextareaBased = CommonProps & Omit, 'as'> & { as: 'textarea'; }; export type FormControlProps = InputBased | TextareaBased; export const FormControl = forwardRef< HTMLInputElement | HTMLTextAreaElement, FormControlProps >((props, ref) => { const { as = 'input', className = '', invalid, ...rest } = props as CommonProps & { as?: 'input' | 'textarea'; [key: string]: unknown; }; const isTextarea = as === 'textarea'; const classes = ['input', isTextarea && 'input--textarea', className] .filter(Boolean) .join(' '); const ariaInvalid = invalid || undefined; if (isTextarea) { return (