Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/with-flow/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
[include]

[libs]
types/

[options]
50 changes: 50 additions & 0 deletions examples/with-flow/types/next.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* @flow */

declare module "next" {
declare type NextApp = {
prepare(): Promise<void>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some more public methods on app.

  • app.render(req, res, pathname: string, query: any)
  • app.renderToHTML(req, res, pathname, query)
  • app.renderError(err, req, res, pathname, query)
  • app.renderErrorToHTML(err, req, res, pathname, query)

https://github.com/zeit/next.js/blob/master/server/index.js#L152

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkzawa Thank you for your notice!
I wrote those types along with README.md and read codes a bit, but I lost them. (It looks not documented yet.) Anyway I add them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkzawa
I added them and getRequestHandler for custom-handler. For https://github.com/zeit/next.js/blob/master/examples/custom-server/server.js#L7

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;
};
}