mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Add next.js flowtype definition to with-flow example (#973)
* Add next.js flowtype definition to with-flow * Add render api types for flow * Add prefetch types * Fix push/replace api types to promise
This commit is contained in:
parent
5b2854dce9
commit
267b74b256
|
@ -3,5 +3,6 @@
|
|||
[include]
|
||||
|
||||
[libs]
|
||||
types/
|
||||
|
||||
[options]
|
||||
|
|
50
examples/with-flow/types/next.js.flow
Normal file
50
examples/with-flow/types/next.js.flow
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* @flow */
|
||||
|
||||
declare module "next" {
|
||||
declare type NextApp = {
|
||||
prepare(): Promise<void>;
|
||||
getRequestHandler(): any;
|
||||
render(req: any, res: any, pathname: string, query: any): any;
|
||||
renderToHTML(req: any, res: any, pathname: string, query: string): string;
|
||||
renderError(err: Error, req: any, res: any, pathname: any, query: any): any;
|
||||
renderErrorToHTML(err: Error, req: any, res: any, pathname: string, query: any): string;
|
||||
};
|
||||
declare module.exports: (...opts: any) => NextApp
|
||||
}
|
||||
|
||||
declare module "next/head" {
|
||||
declare module.exports: Class<React$Component<void, any, any>>;
|
||||
}
|
||||
|
||||
declare module "next/link" {
|
||||
declare module.exports: Class<React$Component<void, {href: string}, any>>;
|
||||
}
|
||||
|
||||
declare module "next/prefetch" {
|
||||
declare export var prefetch: (url: string) => any;
|
||||
declare export var reloadIfPrefetched: any;
|
||||
declare export default Class<React$Component<void, {href: string, prefetch?: boolean}, any>>;
|
||||
}
|
||||
|
||||
declare module "next/router" {
|
||||
declare module.exports: {
|
||||
route: string;
|
||||
pathname: string;
|
||||
query: Object;
|
||||
onRouteChangeStart: ?((url: string) => void);
|
||||
onRouteChangeComplete: ?((url: string) => void);
|
||||
onRouteChangeError: ?((err: Error & {cancelled: boolean}, url: string) => void);
|
||||
push(url: string, as: ?string): Promise<boolean>;
|
||||
replace(url: string, as: ?string): Promise<boolean>;
|
||||
};
|
||||
}
|
||||
|
||||
declare module "next/document" {
|
||||
declare export var Head: Class<React$Component<void, any, any>>;
|
||||
declare export var Main: Class<React$Component<void, any, any>>;
|
||||
declare export var NextScript: Class<React$Component<void, any, any>>;
|
||||
declare export default Class<React$Component<void, any, any>> & {
|
||||
getInitialProps: (ctx: {pathname: string, query: any, req?: any, res?: any, xhr?: any, err?: any}) => Promise<any>;
|
||||
renderPage(cb: Function): void;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue