Skip to content

Commit 267b74b

Browse files
mizchinkzawa
authored andcommitted
Add next.js flowtype definition to with-flow example (vercel#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
1 parent 5b2854d commit 267b74b

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

examples/with-flow/.flowconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
[include]
44

55
[libs]
6+
types/
67

78
[options]

examples/with-flow/types/next.js.flow

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* @flow */
2+
3+
declare module "next" {
4+
declare type NextApp = {
5+
prepare(): Promise<void>;
6+
getRequestHandler(): any;
7+
render(req: any, res: any, pathname: string, query: any): any;
8+
renderToHTML(req: any, res: any, pathname: string, query: string): string;
9+
renderError(err: Error, req: any, res: any, pathname: any, query: any): any;
10+
renderErrorToHTML(err: Error, req: any, res: any, pathname: string, query: any): string;
11+
};
12+
declare module.exports: (...opts: any) => NextApp
13+
}
14+
15+
declare module "next/head" {
16+
declare module.exports: Class<React$Component<void, any, any>>;
17+
}
18+
19+
declare module "next/link" {
20+
declare module.exports: Class<React$Component<void, {href: string}, any>>;
21+
}
22+
23+
declare module "next/prefetch" {
24+
declare export var prefetch: (url: string) => any;
25+
declare export var reloadIfPrefetched: any;
26+
declare export default Class<React$Component<void, {href: string, prefetch?: boolean}, any>>;
27+
}
28+
29+
declare module "next/router" {
30+
declare module.exports: {
31+
route: string;
32+
pathname: string;
33+
query: Object;
34+
onRouteChangeStart: ?((url: string) => void);
35+
onRouteChangeComplete: ?((url: string) => void);
36+
onRouteChangeError: ?((err: Error & {cancelled: boolean}, url: string) => void);
37+
push(url: string, as: ?string): Promise<boolean>;
38+
replace(url: string, as: ?string): Promise<boolean>;
39+
};
40+
}
41+
42+
declare module "next/document" {
43+
declare export var Head: Class<React$Component<void, any, any>>;
44+
declare export var Main: Class<React$Component<void, any, any>>;
45+
declare export var NextScript: Class<React$Component<void, any, any>>;
46+
declare export default Class<React$Component<void, any, any>> & {
47+
getInitialProps: (ctx: {pathname: string, query: any, req?: any, res?: any, xhr?: any, err?: any}) => Promise<any>;
48+
renderPage(cb: Function): void;
49+
};
50+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy