Commit 56c1392b authored by Luis Alvarez D's avatar Luis Alvarez D Committed by Joe Haddad

Use NextComponentType in NextPage (#9575)

parent 0c030669
...@@ -9,11 +9,17 @@ import { NextRouter } from './router/router' ...@@ -9,11 +9,17 @@ import { NextRouter } from './router/router'
/** /**
* Types used by both next and next-server * Types used by both next and next-server
*/ */
export type NextComponentType< export type NextComponentType<
C extends BaseContext = NextPageContext, C extends BaseContext = NextPageContext,
IP = {}, IP = {},
P = {} P = {}
> = ComponentType<P> & { > = ComponentType<P> & {
/**
* Used for initial page load data population. Data returned from `getInitialProps` is serialized when server rendered.
* Make sure to return plain `Object` without using `Date`, `Map`, `Set`.
* @param ctx Context of `page`
*/
getInitialProps?(context: C): IP | Promise<IP> getInitialProps?(context: C): IP | Promise<IP>
} }
......
...@@ -37,17 +37,7 @@ declare module 'react' { ...@@ -37,17 +37,7 @@ declare module 'react' {
/** /**
* `Page` type, use it as a guide to create `pages`. * `Page` type, use it as a guide to create `pages`.
*/ */
export type NextPage<P = {}, IP = P> = { export type NextPage<P = {}, IP = P> = NextComponentType<NextPageContext, IP, P>
(props: P): JSX.Element | null
defaultProps?: Partial<P>
displayName?: string
/**
* Used for initial page load data population. Data returned from `getInitialProps` is serialized when server rendered.
* Make sure to return plain `Object` without using `Date`, `Map`, `Set`.
* @param ctx Context of `page`
*/
getInitialProps?(ctx: NextPageContext): Promise<IP>
}
/** /**
* `Config` type, use it for export const config * `Config` type, use it for export const config
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment