Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit ed71f3a

Browse files
author
v 1 r t l
authored
feat: add AppProps (#380)
* feat: add `AppProps` + replace in all examples * fix(types): replace import alias with http link
1 parent 7ea8f5c commit ed71f3a

File tree

8 files changed

+30
-12
lines changed

8 files changed

+30
-12
lines changed

examples/anchor-links/app.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { ComponentType } from 'react'
1+
import React from 'react'
2+
import { AppProps } from 'aleph/types.d.ts'
23

34
const links = {
45
'Home': '/',
@@ -13,7 +14,7 @@ const links = {
1314
'Dark Green': '/colors/darkgreen?text=orange',
1415
}
1516

16-
export default function App({ Page, pageProps }: { Page: ComponentType<any>, pageProps: any }) {
17+
export default function App({ Page, pageProps }: AppProps) {
1718
return (
1819
<main>
1920
<head>

examples/css-modules/app.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { ComponentType } from 'react'
2+
import { AppProps } from 'aleph/types.d.ts'
23

3-
export default function App({ Page, pageProps }: { Page: ComponentType<any>, pageProps: any }) {
4+
export default function App({ Page, pageProps }: AppProps) {
45
return (
56
<main>
67
<head>

examples/hello-world-spa/app.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import React, { ComponentType } from 'react'
1+
import React from 'react'
2+
import { AppProps } from 'aleph/types.d.ts'
23

3-
export default function App({ Page, pageProps }: { Page: ComponentType<any>, pageProps: any }) {
4+
export default function App({ Page, pageProps }: AppProps) {
45
return (
56
<main>
67
<head>

examples/hello-world/app.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import React, { ComponentType } from 'react'
1+
import React from 'react'
2+
import { AppProps } from 'aleph/types.d.ts'
23

3-
export default function App({ Page, pageProps }: { Page: ComponentType<any>, pageProps: any }) {
4+
export default function App({ Page, pageProps }: AppProps) {
45
return (
56
<main>
67
<head>

examples/markdown-pages/app.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React, { ComponentType } from 'react'
2+
import { AppProps } from 'aleph/types.d.ts'
3+
24

35
type Metadata = {
46
title?: string
57
url?: string
68
}
79

8-
export default function App({ Page, pageProps }: { Page: ComponentType<any> & { meta: Metadata }, pageProps: any }) {
10+
export default function App({ Page, pageProps }: AppProps<Record<string, any>, { meta: Metadata }>) {
911
return (
1012
<main>
1113
<head>

examples/windicss/app.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import React, { ComponentType } from 'react'
1+
import React from 'react'
2+
import { AppProps } from 'aleph/types.d.ts'
23

3-
export default function App({ Page, pageProps }: { Page: ComponentType<any>, pageProps: any }) {
4+
export default function App({ Page, pageProps }: AppProps) {
45
return (
56
<main>
67
<head>

examples/with-src-dir/src/app.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import React, { ComponentType } from 'react'
1+
import React from 'react'
2+
import { AppProps } from 'aleph/types.d.ts'
23

3-
export default function App({ Page, pageProps }: { Page: ComponentType<any>, pageProps: any }) {
4+
export default function App({ Page, pageProps }: AppProps) {
45
return (
56
<main>
67
<head>

types.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { ComponentType } from 'https://esm.sh/[email protected]'
2+
13
/**
24
* An interface that aligns to the parts of the `Aleph` class.
35
*/
@@ -328,3 +330,11 @@ export type RouterURL = {
328330
push(url: string): void
329331
replace(url: string): void
330332
}
333+
334+
/**
335+
* Custom `App` props
336+
*/
337+
export interface AppProps<P extends Record<string, any> = Record<string, any>, T extends {} = {}> {
338+
pageProps: P
339+
Page: ComponentType<P> & T
340+
}

0 commit comments

Comments
 (0)