Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
a7ca0313
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a7ca0313
编写于
5月 06, 2019
作者:
L
Luis Fernando Alvarez D
提交者:
GitHub
5月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Renamed IContext to be NextPageContext (#7272)
上级
e61c1952
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
21 addition
and
20 deletion
+21
-20
packages/next-server/lib/router/router.ts
packages/next-server/lib/router/router.ts
+2
-2
packages/next-server/lib/utils.ts
packages/next-server/lib/utils.ts
+9
-8
packages/next/client/with-router.tsx
packages/next/client/with-router.tsx
+4
-2
packages/next/pages/_app.tsx
packages/next/pages/_app.tsx
+2
-2
packages/next/pages/_error.tsx
packages/next/pages/_error.tsx
+2
-2
packages/next/types/index.d.ts
packages/next/types/index.d.ts
+2
-4
未找到文件。
packages/next-server/lib/router/router.ts
浏览文件 @
a7ca0313
...
...
@@ -3,7 +3,7 @@
import
{
ComponentType
}
from
'
react
'
;
import
{
parse
}
from
'
url
'
;
import
mitt
,
{
MittEmitter
}
from
'
../mitt
'
;
import
{
formatWithValidation
,
getURL
,
loadGetInitialProps
,
I
Context
,
AppContextType
}
from
'
../utils
'
;
import
{
formatWithValidation
,
getURL
,
loadGetInitialProps
,
NextPage
Context
,
AppContextType
}
from
'
../utils
'
;
import
{
rewriteUrlForNextExport
}
from
'
./rewrite-url-for-export
'
function
toRoute
(
path
:
string
):
string
{
...
...
@@ -423,7 +423,7 @@ export default class Router implements BaseRouter {
return
Component
}
async
getInitialProps
(
Component
:
ComponentType
,
ctx
:
I
Context
):
Promise
<
any
>
{
async
getInitialProps
(
Component
:
ComponentType
,
ctx
:
NextPage
Context
):
Promise
<
any
>
{
let
cancelled
=
false
const
cancel
=
()
=>
{
cancelled
=
true
}
this
.
componentLoadCancel
=
cancel
...
...
packages/next-server/lib/utils.ts
浏览文件 @
a7ca0313
...
...
@@ -8,7 +8,7 @@ import { BaseRouter } from './router/router'
/**
* Types used by both next and next-server
*/
export
type
NextComponentType
<
C
extends
BaseContext
=
I
Context
,
IP
=
{},
P
=
{}
>
=
ComponentType
<
P
>
&
{
export
type
NextComponentType
<
C
extends
BaseContext
=
NextPage
Context
,
IP
=
{},
P
=
{}
>
=
ComponentType
<
P
>
&
{
getInitialProps
?(
context
:
C
):
Promise
<
IP
>
,
}
...
...
@@ -31,7 +31,7 @@ export type BaseContext = {
[
k
:
string
]:
any
,
}
export
type
INEXT
DATA
=
{
export
type
NEXT_
DATA
=
{
dataManager
:
string
props
:
any
page
:
string
...
...
@@ -45,7 +45,8 @@ export type INEXTDATA = {
err
?:
Error
&
{
statusCode
?:
number
},
}
export
interface
IContext
{
// tslint:disable-next-line interface-name
export
interface
NextPageContext
{
err
?:
Error
&
{
statusCode
?:
number
}
|
null
req
?:
IncomingMessage
res
?:
ServerResponse
...
...
@@ -55,9 +56,9 @@ export interface IContext {
}
export
type
AppContextType
<
R
extends
BaseRouter
=
BaseRouter
>
=
{
Component
:
NextComponentType
<
I
Context
>
Component
:
NextComponentType
<
NextPage
Context
>
router
:
R
ctx
:
I
Context
,
ctx
:
NextPage
Context
,
}
export
type
AppInitialProps
=
{
...
...
@@ -65,11 +66,11 @@ export type AppInitialProps = {
}
export
type
AppPropsType
<
R
extends
BaseRouter
=
BaseRouter
,
P
=
{}
>
=
AppInitialProps
&
{
Component
:
NextComponentType
<
I
Context
,
any
,
P
>
Component
:
NextComponentType
<
NextPage
Context
,
any
,
P
>
router
:
R
,
}
export
type
DocumentContext
=
I
Context
&
{
export
type
DocumentContext
=
NextPage
Context
&
{
renderPage
:
RenderPage
,
}
...
...
@@ -78,7 +79,7 @@ export type DocumentInitialProps = RenderPageResult & {
}
export
type
DocumentProps
=
DocumentInitialProps
&
{
__NEXT_DATA__
:
INEXT
DATA
__NEXT_DATA__
:
NEXT_
DATA
dangerousAsPath
:
string
ampPath
:
string
amphtml
:
boolean
...
...
packages/next/client/with-router.tsx
浏览文件 @
a7ca0313
import
React
from
'
react
'
import
PropTypes
from
'
prop-types
'
import
{
NextComponentType
,
I
Context
}
from
'
next-server/dist/lib/utils
'
import
{
NextComponentType
,
NextPage
Context
}
from
'
next-server/dist/lib/utils
'
import
{
PublicRouterInstance
}
from
'
./router
'
;
export
type
WithRouterProps
=
{
...
...
@@ -9,7 +9,9 @@ export type WithRouterProps = {
export
type
ExcludeRouterProps
<
P
>
=
Pick
<
P
,
Exclude
<
keyof
P
,
keyof
WithRouterProps
>>
export
default
function
withRouter
<
P
extends
WithRouterProps
,
C
=
IContext
>
(
ComposedComponent
:
NextComponentType
<
C
,
any
,
P
>
):
React
.
ComponentClass
<
ExcludeRouterProps
<
P
>>
{
export
default
function
withRouter
<
P
extends
WithRouterProps
,
C
=
NextPageContext
>
(
ComposedComponent
:
NextComponentType
<
C
,
any
,
P
>
,
):
React
.
ComponentClass
<
ExcludeRouterProps
<
P
>>
{
class
WithRouteWrapper
extends
React
.
Component
<
ExcludeRouterProps
<
P
>>
{
static
displayName
?:
string
static
getInitialProps
?:
any
...
...
packages/next/pages/_app.tsx
浏览文件 @
a7ca0313
import
React
,
{
ErrorInfo
}
from
'
react
'
import
PropTypes
from
'
prop-types
'
import
{
execOnce
,
loadGetInitialProps
,
NextComponentType
,
IContext
,
AppContextType
,
AppInitialProps
,
AppPropsType
}
from
'
next-server/dist/lib/utils
'
import
{
execOnce
,
loadGetInitialProps
,
AppContextType
,
AppInitialProps
,
AppPropsType
}
from
'
next-server/dist/lib/utils
'
import
{
Router
,
makePublicRouterInstance
}
from
'
../client/router
'
export
{
NextComponentType
,
IContext
,
AppInitialProps
}
export
{
AppInitialProps
}
export
type
AppContext
=
AppContextType
<
Router
>
...
...
packages/next/pages/_error.tsx
浏览文件 @
a7ca0313
import
React
from
'
react
'
import
Head
from
'
next-server/head
'
import
{
I
Context
}
from
'
next-server/dist/lib/utils
'
import
{
NextPage
Context
}
from
'
next-server/dist/lib/utils
'
const
statusCodes
:
{
[
code
:
number
]:
string
}
=
{
400
:
'
Bad Request
'
,
...
...
@@ -16,7 +16,7 @@ export type ErrorProps = {
export
default
class
Error
<
P
=
{}
>
extends
React
.
Component
<
P
&
ErrorProps
>
{
static
displayName
=
'
ErrorPage
'
static
getInitialProps
({
res
,
err
}:
I
Context
)
{
static
getInitialProps
({
res
,
err
}:
NextPage
Context
)
{
const
statusCode
=
res
&&
res
.
statusCode
?
res
.
statusCode
:
err
?
err
.
statusCode
:
404
return
{
statusCode
}
...
...
packages/next/types/index.d.ts
浏览文件 @
a7ca0313
import
React
from
'
react
'
import
{
IContext
}
from
'
next-server/dist/lib/utils
'
;
import
{
NextPageContext
,
NextComponentType
}
from
'
next-server/dist/lib/utils
'
;
// Extend the React types with missing properties
declare
module
'
react
'
{
...
...
@@ -20,11 +20,9 @@ declare module 'react' {
}
}
export
type
NextPageContext
=
IContext
export
type
NextPage
<
P
=
{}
>
=
{
(
props
:
P
):
JSX
.
Element
;
getInitialProps
?(
ctx
:
NextPageContext
):
Promise
<
P
>
;
}
export
{
IContext
}
export
{
NextPageContext
,
NextComponentType
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录