[next] Added typings for next/app

This commit is contained in:
Resi Respati
2018-05-11 22:51:14 +07:00
parent ba8d541851
commit 4dff7d9858
3 changed files with 38 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
import * as React from "react";
export interface AppComponentProps {
Component: React.ComponentType<any>;
pageProps: any
}
export class Container extends React.Component {}
export default class App<P = {}> extends React.Component<P & AppComponentProps> {}
+27
View File
@@ -0,0 +1,27 @@
import * as React from "react";
import App, { Container } from "next/app";
interface NextComponentProps {
example: string;
}
class TestApp extends App<NextComponentProps> {
static async getInitialProps({ Component, router, ctx }: any) {
let pageProps = {};
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx);
}
return { pageProps };
}
render() {
const { Component, pageProps } = this.props;
return (
<Container>
<Component {...pageProps} />
</Container>
);
}
}
+1
View File
@@ -28,6 +28,7 @@
"router.d.ts",
"config.d.ts",
"test/next-tests.ts",
"test/next-app-tests.tsx",
"test/next-error-tests.tsx",
"test/next-head-tests.tsx",
"test/next-document-tests.tsx",