@types/next
Advanced tools
Comparing version 2.4.12 to 6.0.0
import * as React from "react"; | ||
import * as http from "http"; | ||
import { NextContext } from "."; | ||
export interface Context { | ||
err?: Error; | ||
req: http.IncomingMessage; | ||
res: http.ServerResponse; | ||
pathname: string; | ||
query?: { | ||
[key: string]: | ||
| boolean | ||
| boolean[] | ||
| number | ||
| number[] | ||
| string | ||
| string[]; | ||
}; | ||
asPath: string; | ||
renderPage( | ||
enhancer?: (page: React.Component) => React.ComponentType<any> | ||
): { | ||
html?: string; | ||
head: Array<React.ReactElement<any>>; | ||
errorHtml: string; | ||
}; | ||
} | ||
export interface DocumentProps { | ||
@@ -41,2 +16,14 @@ __NEXT_DATA__?: any; | ||
/** | ||
* Context object used inside `Document` | ||
*/ | ||
export interface NextDocumentContext extends NextContext { | ||
/** A callback that executes the actual React rendering logic (synchronously) */ | ||
renderPage( | ||
cb?: (enhancer: () => JSX.Element) => React.ComponentType<any> | ||
): { | ||
[key: string]: any | ||
}; | ||
} | ||
export class Head extends React.Component<any> {} | ||
@@ -46,3 +33,3 @@ export class Main extends React.Component {} | ||
export default class extends React.Component<DocumentProps> { | ||
static getInitialProps(ctx: Context): DocumentProps; | ||
static getInitialProps(ctx: NextContext): DocumentProps; | ||
} |
@@ -1,5 +0,7 @@ | ||
// Type definitions for next 2.4 | ||
// Type definitions for next 6.0 | ||
// Project: https://github.com/zeit/next.js | ||
// Definitions by: Drew Hays <https://github.com/dru89> | ||
// Brice BERNARD <https://github.com/brikou> | ||
// James Hegedus <https://github.com/jthegedus> | ||
// Resi Respati <https://github.com/resir014> | ||
// Scott Jones <https://github.com/scottdj92> | ||
@@ -14,3 +16,40 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
import { Response as NodeResponse } from "node-fetch"; | ||
declare namespace next { | ||
/** | ||
* Context object used in methods like `getInitialProps()` | ||
* <<https://github.com/zeit/next.js/issues/1651>> | ||
*/ | ||
interface NextContext { | ||
/** path section of URL */ | ||
pathname: string; | ||
/** query string section of URL parsed as an object */ | ||
query: { | ||
[key: string]: | ||
| boolean | ||
| boolean[] | ||
| number | ||
| number[] | ||
| string | ||
| string[]; | ||
}; | ||
/** String of the actual path (including the query) shows in the browser */ | ||
asPath: string; | ||
/** HTTP request object (server only) */ | ||
req?: http.IncomingMessage; | ||
/** HTTP response object (server only) */ | ||
res?: http.ServerResponse; | ||
/** Fetch Response object (client only) - from https://developer.mozilla.org/en-US/docs/Web/API/Response */ | ||
jsonPageRes?: NodeResponse; | ||
/** Error object if any error is encountered during the rendering */ | ||
err?: Error; | ||
} | ||
type NextSFC<TProps = {}> = NextStatelessComponent<TProps>; | ||
interface NextStatelessComponent<TProps = {}> | ||
extends React.StatelessComponent<TProps> { | ||
getInitialProps?: (ctx: NextContext) => Promise<TProps>; | ||
} | ||
type UrlLike = url.UrlObject | url.Url; | ||
@@ -45,3 +84,3 @@ | ||
res: http.ServerResponse, | ||
parsedUrl?: UrlLike, | ||
parsedUrl?: UrlLike | ||
): Promise<void>; | ||
@@ -51,3 +90,3 @@ getRequestHandler(): ( | ||
res: http.ServerResponse, | ||
parsedUrl?: UrlLike, | ||
parsedUrl?: UrlLike | ||
) => Promise<void>; | ||
@@ -61,3 +100,3 @@ prepare(): Promise<void>; | ||
res: http.ServerResponse, | ||
parsedUrl: UrlLike, | ||
parsedUrl: UrlLike | ||
): Promise<void>; | ||
@@ -78,3 +117,3 @@ | ||
}, | ||
parsedUrl?: UrlLike, | ||
parsedUrl?: UrlLike | ||
): Promise<void>; | ||
@@ -94,3 +133,3 @@ renderError( | ||
| string[]; | ||
}, | ||
} | ||
): Promise<void>; | ||
@@ -100,3 +139,3 @@ render404( | ||
res: http.ServerResponse, | ||
parsedUrl: UrlLike, | ||
parsedUrl: UrlLike | ||
): Promise<void>; | ||
@@ -115,3 +154,3 @@ renderToHTML( | ||
| string[]; | ||
}, | ||
} | ||
): Promise<string>; | ||
@@ -131,3 +170,3 @@ renderErrorToHTML( | ||
| string[]; | ||
}, | ||
} | ||
): Promise<string>; | ||
@@ -138,3 +177,3 @@ | ||
res: http.ServerResponse, | ||
path: string, | ||
path: string | ||
): Promise<void>; | ||
@@ -148,3 +187,3 @@ isServeableUrl(path: string): boolean; | ||
req: http.IncomingMessage, | ||
res: http.ServerResponse, | ||
res: http.ServerResponse | ||
): Promise<any>; | ||
@@ -154,3 +193,3 @@ handleBuildHash( | ||
hash: string, | ||
res: http.ServerResponse, | ||
res: http.ServerResponse | ||
): void; | ||
@@ -157,0 +196,0 @@ send404(res: http.ServerResponse): void; |
{ | ||
"name": "@types/next", | ||
"version": "2.4.12", | ||
"version": "6.0.0", | ||
"description": "TypeScript definitions for next", | ||
@@ -18,2 +18,12 @@ "license": "MIT", | ||
{ | ||
"name": "James Hegedus", | ||
"url": "https://github.com/jthegedus", | ||
"githubUsername": "jthegedus" | ||
}, | ||
{ | ||
"name": "Resi Respati", | ||
"url": "https://github.com/resir014", | ||
"githubUsername": "resir014" | ||
}, | ||
{ | ||
"name": "Scott Jones", | ||
@@ -31,7 +41,8 @@ "url": "https://github.com/scottdj92", | ||
"dependencies": { | ||
"@types/node-fetch": "*", | ||
"@types/node": "*", | ||
"@types/react": "*" | ||
}, | ||
"typesPublisherContentHash": "fb82e5974fc978fff3f56ab10501c3de5b3d9c78b139f69ea00b06b434409163", | ||
"typesPublisherContentHash": "5a6035df64b7a1cb9dd2eb0f22fa90ca68b446aeaf7720acdc3b25c4aa404b60", | ||
"typeScriptVersion": "2.6" | ||
} |
@@ -11,7 +11,7 @@ # Installation | ||
Additional Details | ||
* Last updated: Mon, 11 Jun 2018 20:24:44 GMT | ||
* Dependencies: http, url, node, react | ||
* Last updated: Wed, 13 Jun 2018 19:16:57 GMT | ||
* Dependencies: http, url, node-fetch, node, react | ||
* Global values: none | ||
# Credits | ||
These definitions were written by Drew Hays <https://github.com/dru89>, Brice BERNARD <https://github.com/brikou>, Scott Jones <https://github.com/scottdj92>. | ||
These definitions were written by Drew Hays <https://github.com/dru89>, Brice BERNARD <https://github.com/brikou>, James Hegedus <https://github.com/jthegedus>, Resi Respati <https://github.com/resir014>, Scott Jones <https://github.com/scottdj92>. |
13876
12
328
3
+ Added@types/node-fetch@*
+ Added@types/node-fetch@3.0.3(transitive)
+ Addeddata-uri-to-buffer@4.0.1(transitive)
+ Addedfetch-blob@3.2.0(transitive)
+ Addedformdata-polyfill@4.0.10(transitive)
+ Addednode-domexception@1.0.0(transitive)
+ Addednode-fetch@3.3.2(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)