Skip to content

Commit

Permalink
Update params of PageProps to string map (#41677)
Browse files Browse the repository at this point in the history
x-ref: #41668

Update `PageProps` to `Record<string, string>`

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
huozhi and ijjk committed Oct 23, 2022
1 parent 70a128e commit 374ca38
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/next/build/webpack/plugins/flight-types-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ type TEntry = typeof entry
check<IEntry, TEntry>(entry)
type PageProps = { params?: any }
type LayoutProps = { children: React.ReactNode; params?: any }
type PageParams = Record<string, string>
interface PageProps {
params?: PageParams
searchParams?: Record<string, string | string[]>
}
interface LayoutProps {
children: React.ReactNode
params?: PageParams
}

This comment has been minimized.

Copy link
@rijk

rijk Nov 12, 2022

Could these types be exported? I'm getting a build error when trying to type these myself:

Type error: Page "app/[organization]/account/confirm/page.tsx" does not match the required types of a Next.js Page.
  Invalid configuration:
    The exported page component isn't correctly typed.
        Expected "PageParams<Record<string, string>, Record<string, string | string[]>>", got "PageProps".

No matter what type I use (even if I use the exact same interface as above).

type PageComponent = (props: PageProps) => React.ReactNode | null
type LayoutComponent = (props: LayoutProps) => React.ReactNode | null
Expand All @@ -39,7 +46,7 @@ interface IEntry {
}
config?: {}
Head?: any
generateStaticParams?: (params?:any) => Promise<any[]>
generateStaticParams?: (params?: PageParams) => Promise<any[]>
revalidate?: RevalidateRange<TEntry> | false
dynamic?: 'auto' | 'force-dynamic' | 'error' | 'force-static'
dynamicParams?: boolean
Expand Down

0 comments on commit 374ca38

Please sign in to comment.