aboutsummaryrefslogtreecommitdiffstats
path: root/src/ts/types/app.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-09-21 12:20:18 +0200
committerArmand Philippot <git@armandphilippot.com>2022-09-21 12:20:18 +0200
commit08c7b3d0eb2ced622cdd3c4d14a3958ac8161cb8 (patch)
tree8383bde62089a434a75bd39a0db375e7e63bd602 /src/ts/types/app.ts
parent0386d1854ddf9c8edde88e8caeffbfc2853de670 (diff)
fix(types): add custom types to pageProps with translation
Diffstat (limited to 'src/ts/types/app.ts')
-rw-r--r--src/ts/types/app.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ts/types/app.ts b/src/ts/types/app.ts
index c11c31b..64bb3af 100644
--- a/src/ts/types/app.ts
+++ b/src/ts/types/app.ts
@@ -1,6 +1,7 @@
import { NextPage } from 'next';
-import { AppProps } from 'next/app';
+import { AppProps as NextAppProps } from 'next/app';
import { ReactElement, ReactNode } from 'react';
+import { MessageFormatElement } from 'react-intl';
export type NextPageWithLayoutOptions = {
withExtraPadding?: boolean;
@@ -15,7 +16,16 @@ export type NextPageWithLayout<T = {}> = NextPage<T> & {
) => ReactNode;
};
-export type AppPropsWithLayout = AppProps & {
+// modified version - allows for custom pageProps type, falling back to 'any'
+type AppProps<P = any> = {
+ pageProps: P;
+} & Omit<NextAppProps<P>, 'pageProps'>;
+
+type CustomPageProps = {
+ translation: Record<string, string> | Record<string, MessageFormatElement[]>;
+};
+
+export type AppPropsWithLayout = AppProps<CustomPageProps> & {
Component: NextPageWithLayout;
};