diff --git a/src/index.ts b/src/index.ts index a650b43..d2fb258 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,20 +12,13 @@ export { VariantProps, ClassProp, VariantsSchema, VariantsConfig, ClassValue } export type IntrinsicElementsKeys = keyof JSX.IntrinsicElements -type ForwardRefFunction = { - (props: any, ref?: any): any -} - -export type VariantOBJ = +type VariantOBJ = | (Variants extends VariantsSchema ? VariantsConfig & ClassProp : ClassProp) | undefined -export function styled( - Tag: T, - forwardRef?: ForwardRefFunction, -) { +export function styled(Tag: T) { return function wrapper( base?: ClassValue, config?: @@ -70,7 +63,7 @@ export function styled( _props.className = cx(classes(), props.className) } - if (forwardRef) { + if (ref) { _props.ref = ref } @@ -79,6 +72,6 @@ export function styled( return React.createElement(_as, _props) } - return forwardRef ? forwardRef(StyledWrapper) : StyledWrapper + return React.forwardRef(StyledWrapper) } }