gladly-team/next-firebase-auth

How to resolve the return type of getServerSideProps?

MathiasPawshake opened this issue · 0 comments

Hi

I looked into the example page: https://github.com/gladly-team/next-firebase-auth/blob/main/example/pages/ssr-no-token.tsx
There you will see that the export default is the following:

export default withUser<DataType>({
  whenUnauthedAfterInit: AuthAction.REDIRECT_TO_LOGIN,
})(Demo)

The props of the page will be DataType which is fine. The only issue is that when you would forget to pass favoriteColor in the getServerSideProps, typescript will not throw an error that this property is missing.

If we would declare the getServerSideProps as following (without the next-firebase-auth, just as an example):

export const getServerSideProps: GetServerSideProps<DataType> = (ctx) => {
    // other code
    return {
        props: {
            favoriteColor: data.favoriteColor,
        },
    };
};

We would get a typescript error that favoriteColor is missing.

Is there a way to achieve this with the current typescript setup in next-firebase-auth?