UNPKG

1.71 kBTypeScriptView Raw
1import * as React from "react";
2
3import { NextContext } from ".";
4
5export interface RenderPageResponse {
6 buildManifest: { [key: string]: any };
7 chunks: {
8 names: string[];
9 filenames: string[];
10 };
11 html?: string;
12 head: Array<React.ReactElement<any>>;
13 errorHtml: string;
14}
15
16export interface PageProps {
17 url: string;
18}
19
20export interface AnyPageProps extends PageProps {
21 [key: string]: any;
22}
23
24export type Enhancer<E extends PageProps = AnyPageProps, P extends any = E> = (page: React.ComponentType<P>) => React.ComponentType<E>;
25
26/**
27 * Context object used inside `Document`
28 */
29export interface NextDocumentContext extends NextContext {
30 /** A callback that executes the actual React rendering logic (synchronously) */
31 renderPage<E extends PageProps = AnyPageProps, P extends any = E>(enhancer?: Enhancer<E, P>): RenderPageResponse; // tslint:disable-line:no-unnecessary-generics
32}
33
34export interface DocumentProps {
35 __NEXT_DATA__?: any;
36 dev?: boolean;
37 chunks?: {
38 names: string[];
39 filenames: string[];
40 };
41 html?: string;
42 head?: Array<React.ReactElement<any>>;
43 errorHtml?: string;
44 styles?: Array<React.ReactElement<any>>;
45 [key: string]: any;
46}
47
48export interface HeadProps {
49 nonce?: string;
50 [key: string]: any;
51}
52
53export interface NextScriptProps {
54 nonce?: string;
55}
56
57export class Head extends React.Component<HeadProps> {}
58export class Main extends React.Component {}
59export class NextScript extends React.Component<NextScriptProps> {}
60export default class extends React.Component<DocumentProps> {
61 static getInitialProps(ctx: NextDocumentContext): Promise<DocumentProps> | DocumentProps;
62}