From 4dff7d985840fbe92101a8d5d3d8b5ccca9eb5f8 Mon Sep 17 00:00:00 2001 From: Resi Respati Date: Fri, 11 May 2018 22:51:14 +0700 Subject: [PATCH] [next] Added typings for `next/app` --- types/next/app.d.ts | 10 ++++++++++ types/next/test/next-app-tests.tsx | 27 +++++++++++++++++++++++++++ types/next/tsconfig.json | 1 + 3 files changed, 38 insertions(+) create mode 100644 types/next/app.d.ts create mode 100644 types/next/test/next-app-tests.tsx diff --git a/types/next/app.d.ts b/types/next/app.d.ts new file mode 100644 index 0000000000..6d10d77af8 --- /dev/null +++ b/types/next/app.d.ts @@ -0,0 +1,10 @@ +import * as React from "react"; + +export interface AppComponentProps { + Component: React.ComponentType; + pageProps: any +} + +export class Container extends React.Component {} + +export default class App

extends React.Component

{} diff --git a/types/next/test/next-app-tests.tsx b/types/next/test/next-app-tests.tsx new file mode 100644 index 0000000000..3e7c56f87c --- /dev/null +++ b/types/next/test/next-app-tests.tsx @@ -0,0 +1,27 @@ +import * as React from "react"; +import App, { Container } from "next/app"; + +interface NextComponentProps { + example: string; +} + +class TestApp extends App { + 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 ( + + + + ); + } +} diff --git a/types/next/tsconfig.json b/types/next/tsconfig.json index d22768e4a1..36aef39491 100644 --- a/types/next/tsconfig.json +++ b/types/next/tsconfig.json @@ -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",