mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-01-30 21:47:35 +00:00
Please fill in this template. - [x] Use a meaningful title for the pull request. Include the name of the package modified. - [x] Test the change in your own code. (Compile and run.) - [ ] Add or edit tests to reflect the change. (Run with `npm test`.) - [x] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). - [x] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [x] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present). Select one of these and delete the others: If changing an existing definition: - [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <<url here>> - [x] Increase the version number in the header if appropriate. - [x] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "dtslint/dt.json" }`. I'm not familiar with writing these kind of testing code, so I didn't update that. Give me some guidance if necessary. Thanks.
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import * as React from "react";
|
|
|
|
import { NextContext } from ".";
|
|
|
|
export interface RenderPageResponse {
|
|
buildManifest: { [key: string]: any };
|
|
chunks: {
|
|
names: string[];
|
|
filenames: string[];
|
|
};
|
|
html?: string;
|
|
head: Array<React.ReactElement<any>>;
|
|
errorHtml: string;
|
|
}
|
|
|
|
export interface PageProps {
|
|
url: string;
|
|
}
|
|
|
|
export interface AnyPageProps extends PageProps {
|
|
[key: string]: any;
|
|
}
|
|
|
|
export type Enhancer<E extends PageProps = AnyPageProps, P extends any = E> = (page: React.ComponentType<P>) => React.ComponentType<E>;
|
|
|
|
/**
|
|
* Context object used inside `Document`
|
|
*/
|
|
export interface NextDocumentContext extends NextContext {
|
|
/** A callback that executes the actual React rendering logic (synchronously) */
|
|
renderPage<E extends PageProps = AnyPageProps, P extends any = E>(enhancer?: Enhancer<E, P>): RenderPageResponse; // tslint:disable-line:no-unnecessary-generics
|
|
}
|
|
|
|
export interface DocumentProps {
|
|
__NEXT_DATA__?: any;
|
|
dev?: boolean;
|
|
chunks?: {
|
|
names: string[];
|
|
filenames: string[];
|
|
};
|
|
html?: string;
|
|
head?: Array<React.ReactElement<any>>;
|
|
errorHtml?: string;
|
|
styles?: Array<React.ReactElement<any>>;
|
|
[key: string]: any;
|
|
}
|
|
|
|
export interface HeadProps {
|
|
nonce?: string;
|
|
[key: string]: any;
|
|
}
|
|
|
|
export interface NextScriptProps {
|
|
nonce?: string;
|
|
}
|
|
|
|
export class Head extends React.Component<HeadProps> {}
|
|
export class Main extends React.Component {}
|
|
export class NextScript extends React.Component<NextScriptProps> {}
|
|
export default class Document<TProps = {}> extends React.Component<TProps & DocumentProps> {
|
|
static getInitialProps(ctx: NextDocumentContext): Promise<DocumentProps> | DocumentProps;
|
|
}
|