bug(typedef): AppType typedef changed in 12.3
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000
Binaries:
Node: 16.15.1
npm: 8.11.0
Yarn: 1.22.19
pnpm: 7.10.0
Relevant packages:
next: 12.3.0
eslint-config-next: 12.3.0
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
When bumping version to Next 12.3.0 we ran into some troubles with the AppType typedefinition:
The AppType typedefinition and specifically the pageProps seems to have been broken in 12.3.0 and the pageProps now evaluates to {}:
Expected Behavior
I am not sure if this is a bug or if it’s intended, but this change is not present in the changelog and seems to be a “breaking” one worth noting. Maybe we are required to augment some part to make it work with 3rd party dependencies?
Link to reproduction
https://github.com/juliusmarminge/apptype-repro
To Reproduce
Create a new next-app (using reproduction template):
npx create-next-app -e reproduction-template
Install NextAuth:
nom install next-auth
Create pages/_app.tsx
with the following content:
import { SessionProvider } from "next-auth/react";
import type { AppType } from "next/dist/shared/lib/utils";
const MyApp: AppType = ({ Component, pageProps }) => {
return (
<SessionProvider session={pageProps.session}>
<Component {...pageProps} />
</SessionProvider>
);
};
Hover pageProps, it evaluates to {} and the pageProps.session will error. This was not an issue in 12.2.5.
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:6 (4 by maintainers)
To be clear i think this is a very good improvement and seems like it would allow for a more typesafe usage in the root app.
Maybe the AppType should be a generic like NextPage, or React.FC and letting me pass in the props like
Yes, it makes more sense as a feature request, I started working on it already. See #40391