withPageAuthRequired fails type check with typed props

Hi.

I am working on nextjs app and I have a NextPage component that receives props from getStaticProps function. The component is wrapped inside the withPageAuthRequired() call. My build fails with the following error:

Type error: No overload matches this call.
  Overload 1 of 2, '(opts?: WithPageAuthRequiredOptions<unknown> | undefined): PageRoute<unknown>', gave the following error.
    Type '({ deals }: { deals: DealResponse[]; }) => Element' has no properties in common with type 'WithPageAuthRequiredOptions<unknown>'.
  Overload 2 of 2, '(Component: ComponentType<WithPageAuthRequiredProps>, options?: WithPageAuthRequiredOptions | undefined): FC<...>', gave the following error.
    Argument of type '({ deals }: { deals: DealResponse[]; }) => Element' is not assignable to parameter of type 'ComponentType<WithPageAuthRequiredProps>'.
      Type '({ deals }: { deals: DealResponse[]; }) => Element' is not assignable to type 'FunctionComponent<WithPageAuthRequiredProps>'.
        Types of parameters '__0' and 'props' are incompatible.
          Property 'deals' is missing in type 'PropsWithChildren<WithPageAuthRequiredProps>' but required in type '{ deals: DealResponse[]; }'.

  89 | };

It works as long as props don’t have a type but I need my props typed. How can I make this work?

UPDATE: I managed to work around it by casting the component to any type like export default withPageAuthRequired(History as any);. It would be cool to find another way of making it work though.

Sharing your workaround as a temporary solution for now:

UPDATE: I managed to work around it by casting the component to any type like export default withPageAuthRequired(History as any); . It would be cool to find another way of making it work though.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.