Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
56c1392b
Commit
56c1392b
authored
Dec 03, 2019
by
Luis Alvarez D
Committed by
Joe Haddad
Dec 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use NextComponentType in NextPage (#9575)
parent
0c030669
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
utils.ts
packages/next/next-server/lib/utils.ts
+6
-0
index.d.ts
packages/next/types/index.d.ts
+1
-11
No files found.
packages/next/next-server/lib/utils.ts
View file @
56c1392b
...
@@ -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
>
}
}
...
...
packages/next/types/index.d.ts
View file @
56c1392b
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment