Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NextJS Infer type lead to props: never #279

Closed
binajmen opened this issue Aug 18, 2021 · 3 comments
Closed

NextJS Infer type lead to props: never #279

binajmen opened this issue Aug 18, 2021 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@binajmen
Copy link

Describe the bug
NextJS Infer type lead to props: never when encapsulating the page with next-firebase-auth

Version
^0.13.3-alpha.1

To Reproduce

import type { InferGetServerSidePropsType } from 'next'
import { AuthAction, useAuthUser, withAuthUser, withAuthUserTokenSSR } from 'next-firebase-auth'

function Page(props: InferGetServerSidePropsType<typeof getServerSideProps>) {
  const user = useAuthUser()

  return (
    //                   v-- Property 'message' does not exist on type 'never'.ts(2339)
    <div>Message: {props.message} from {user.id}</div> 
  )
}

export default withAuthUser<InferGetServerSidePropsType<typeof getServerSideProps>>({
  whenUnauthedBeforeInit: AuthAction.SHOW_LOADER,
  whenUnauthedAfterInit: AuthAction.REDIRECT_TO_LOGIN
})(Page)

export const getServerSideProps = withAuthUserTokenSSR({
  whenUnauthed: AuthAction.REDIRECT_TO_LOGIN,
})(async ({ AuthUser }) => {
  console.log(AuthUser.id)

  return { props: { message: "Hello" } }
})

Expected behavior
I would expect to have a proper typed props: { message: string }

Additional context
If you remove next-firebase-auth out of the equation, typing is correct

@basilmahmood
Copy link

Getting the same behaviour

@kmjennison
Copy link
Contributor

Related: vercel/next.js#15913

Help welcome on this.

@kmjennison kmjennison added the help wanted Extra attention is needed label Aug 27, 2021
@kmjennison
Copy link
Contributor

I believe this is closed by #283. See docs and example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants