Improve types (#8097)
This commit is contained in:
parent
427a02a468
commit
55e87ea50c
3 changed files with 5 additions and 3 deletions
|
@ -215,7 +215,7 @@ export async function loadGetInitialProps<
|
|||
C extends BaseContext,
|
||||
IP = {},
|
||||
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 (Component.prototype && Component.prototype.getInitialProps) {
|
||||
const message = `"${getDisplayName(
|
||||
|
|
|
@ -112,7 +112,7 @@ function getRouter() {
|
|||
export default singletonRouter as SingletonRouter
|
||||
|
||||
// Reexport the withRoute HOC
|
||||
export { default as withRouter } from './with-router'
|
||||
export { default as withRouter, WithRouterProps } from './with-router'
|
||||
|
||||
export function useRouter() {
|
||||
return React.useContext(RouterContext)
|
||||
|
|
4
packages/next/types/index.d.ts
vendored
4
packages/next/types/index.d.ts
vendored
|
@ -38,7 +38,9 @@ declare module 'react' {
|
|||
* `Page` type, use it as a guide to create `pages`.
|
||||
*/
|
||||
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.
|
||||
* Make sure to return plain `Object` without using `Date`, `Map`, `Set`.
|
||||
|
|
Loading…
Reference in a new issue