next.js
next.js copied to clipboard
fix: correct AppType parameter usage for TypeScript
Description
Fixes #42846
The AppType generic parameter P was incorrectly used as InitialProps instead of PageProps. This fix properly uses AppInitialProps<PageProps> for the InitialProps parameter to match the actual structure where pageProps is wrapped in an object.
Changes
Before:
export type AppType<P = {}> = NextComponentType<
AppContextType,
P,
AppPropsType<any, P>
>
After:
export type AppType<PageProps = {}> = NextComponentType<
AppContextType,
AppInitialProps<PageProps>,
AppPropsType<any, PageProps>
>
Why This Fix?
According to NextComponentType definition:
- 1st param: Context
- 2nd param: InitialProps (should be
AppInitialProps<PageProps>) - 3rd param: Props (already correctly using
AppPropsType<any, PageProps>)
The parameter name is also changed from P to PageProps for clarity.
Testing
- TypeScript compilation passes
- Type definitions now correctly reflect the actual structure
Allow CI Workflow Run
- [ ] approve CI run for commit: e32c0607413506c7a272438c7dbc080939016a7f
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer