Skip to content

Commit efbabd2

Browse files
authored
Convert with-app-layout example to TypeScript (vercel#42930)
Converted example to TypeScript to match Contribution docs. ## Documentation / Examples - [X] Make sure the linting passes by running `pnpm build && pnpm lint` - [X] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
1 parent 0e8f241 commit efbabd2

File tree

6 files changed

+44
-10
lines changed

6 files changed

+44
-10
lines changed

examples/with-app-layout/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# With `App` layout example
22

3-
Shows how to use \_app.js to implement a global layout for all pages.
3+
Shows how to use `_app.tsx` to implement a global layout for all pages.
44

55
## Deploy your own
66

examples/with-app-layout/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,11 @@
99
"next": "latest",
1010
"react": "^18.2.0",
1111
"react-dom": "^18.2.0"
12+
},
13+
"devDependencies": {
14+
"@types/node": "^18.11.9",
15+
"@types/react": "^18.0.25",
16+
"@types/react-dom": "^18.0.9",
17+
"typescript": "^4.8.4"
1218
}
1319
}

examples/with-app-layout/pages/_app.js

-9
This file was deleted.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { AppProps } from 'next/app'
2+
3+
interface LayoutProps {
4+
children: React.ReactNode
5+
}
6+
7+
const Layout = ({ children }: LayoutProps) => (
8+
<div className="layout">{children}</div>
9+
)
10+
11+
export default function App({ Component, pageProps }: AppProps) {
12+
return (
13+
<Layout>
14+
<Component {...pageProps} />
15+
</Layout>
16+
)
17+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": false,
8+
"forceConsistentCasingInFileNames": true,
9+
"noEmit": true,
10+
"esModuleInterop": true,
11+
"module": "esnext",
12+
"moduleResolution": "node",
13+
"resolveJsonModule": true,
14+
"isolatedModules": true,
15+
"jsx": "preserve",
16+
"incremental": true
17+
},
18+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
19+
"exclude": ["node_modules"]
20+
}

0 commit comments

Comments
 (0)