Skip to content

Commit

Permalink
Fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mad-Kat committed Dec 9, 2024
1 parent 2fd4bec commit 1c0de12
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions packages/next-yak/runtime/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ import type { YakTheme } from "./context/index.d.ts";
*/
const noTheme: YakTheme = {};

/**
* Hack to hide {[yakComponentSymbol]:[parentComponent, parentAttributeFunction]}
* from the type definition and to deal with ExoticComponents
*/
const yakForwardRef: <
TProps,
TAttrsIn extends object,
TAttrsOut extends AttrsMerged<TProps, TAttrsIn>,
>(
component: ForwardRefRenderFunction<any, TProps>,
attrsFn?: (props: any) => any,
) => YakComponent<TProps, TAttrsIn, TAttrsOut> = (component, attrsFn) =>
Object.assign(React.forwardRef(component as any), {
[yakComponentSymbol]: [component, attrsFn],
}) as any;

/**
* Minimal type for a function component that works with next-yak
*/
Expand Down Expand Up @@ -227,7 +211,11 @@ const yakStyled = <
// Assign the yakComponentSymbol directly without forwardRef
return Object.assign(yak, {
[yakComponentSymbol]: [yak, mergedAttrsFn],
});
}) as YakComponent<
Substitute<TCSSProps & T, TAttrsIn>,
object,
AttrsMerged<Substitute<TCSSProps & T, TAttrsIn>, object>
>;
};
};

Expand Down

0 comments on commit 1c0de12

Please sign in to comment.