Skip to content

Fix: parameter on AppType incorrectly applied to pageProps instead of props#92968

Closed
Jah-yee wants to merge 0 commit intovercel:canaryfrom
Jah-yee:canary
Closed

Fix: parameter on AppType incorrectly applied to pageProps instead of props#92968
Jah-yee wants to merge 0 commit intovercel:canaryfrom
Jah-yee:canary

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 18, 2026

Good day

Bug Description

When using AppType<MyInitialProps>, the type parameter was incorrectly applied only to MyApp.props.pageProps via AppInitialProps<PageProps>, instead of directly to MyApp.props.

This caused a TypeScript error on props.foo (which exists at runtime) while incorrectly showing no error on pageProps.foo (which does not exist at runtime).

Root Cause

In AppPropsType<Router, PageProps>, the PageProps type parameter was only used within AppInitialProps<PageProps> which wraps it in a pageProps property. The raw PageProps was not included in the props intersection.

Fix

Changed AppPropsType from:

export type AppPropsType<Router, PageProps = {}> = AppInitialProps<PageProps> & {
  Component: ...
}

to:

export type AppPropsType<Router, PageProps = {}> = AppInitialProps<PageProps> & PageProps & {
  Component: ...
}

This ensures that when AppType<P> is used, the parameter P is correctly applied to props directly (via both AppInitialProps for pageProps and the intersection with PageProps itself).

Files Changed

  • packages/next/src/shared/lib/utils.ts: Added PageProps to the intersection in AppPropsType

Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly, RoomWithOutRoof

Comment thread packages/next/src/shared/lib/utils.ts Outdated
Router extends NextRouter = NextRouter,
PageProps = {},
> = AppInitialProps<PageProps> & {
> = AppInitialProps<PageProps> & PageProps & {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding & PageProps to AppPropsType causes the PageProps type parameter to incorrectly leak onto the top-level component props, breaking the common AppProps<P> pattern where P should only describe pageProps.

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants