Add ErrorTestAppWithState to Next.js' tests

This commit is contained in:
Josias Iquabius 2019-01-26 09:04:58 -03:00
parent af36b57821
commit 24106b4e6d

View File

@ -6,6 +6,10 @@ interface TestAppProps {
pageProps: any;
}
interface TestAppState {
color: string;
}
interface TypedQuery extends DefaultQuery {
id?: string;
}
@ -33,6 +37,20 @@ class TestAppWithProps extends App<TestAppProps & WithExampleProps> {
}
}
class ErrorTestAppWithState extends App<TestAppProps & WithExampleProps, TestAppState> {
static async getInitialProps({ Component, router, ctx }: NextAppContext) {
const pageProps = Component.getInitialProps && (await Component.getInitialProps(ctx));
return { pageProps };
}
render() {
const { Component, router, pageProps, example } = this.props;
return <Component {...pageProps} example={example} />;
}
state: {}; // $ExpectError
}
class TestAppWithTypedQuery extends App {
static async getInitialProps({ ctx }: NextAppContext<TypedQuery>) {
const { id } = ctx.query;