Commit 55e87ea5 authored by Adam Misiorny's avatar Adam Misiorny Committed by Luis Fernando Alvarez D

Improve types (#8097)

parent 427a02a4
...@@ -215,7 +215,7 @@ export async function loadGetInitialProps< ...@@ -215,7 +215,7 @@ export async function loadGetInitialProps<
C extends BaseContext, C extends BaseContext,
IP = {}, IP = {},
P = {} P = {}
>(Component: NextComponentType<C, IP, P>, ctx: C): Promise<IP | null> { >(Component: NextComponentType<C, IP, P>, ctx: C): Promise<IP> {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
if (Component.prototype && Component.prototype.getInitialProps) { if (Component.prototype && Component.prototype.getInitialProps) {
const message = `"${getDisplayName( const message = `"${getDisplayName(
......
...@@ -112,7 +112,7 @@ function getRouter() { ...@@ -112,7 +112,7 @@ function getRouter() {
export default singletonRouter as SingletonRouter export default singletonRouter as SingletonRouter
// Reexport the withRoute HOC // Reexport the withRoute HOC
export { default as withRouter } from './with-router' export { default as withRouter, WithRouterProps } from './with-router'
export function useRouter() { export function useRouter() {
return React.useContext(RouterContext) return React.useContext(RouterContext)
......
...@@ -38,7 +38,9 @@ declare module 'react' { ...@@ -38,7 +38,9 @@ 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> = {
(props: P): JSX.Element (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. * 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`. * Make sure to return plain `Object` without using `Date`, `Map`, `Set`.
......
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