Skip to content

Commit

Permalink
Convert with-app-layout example to TypeScript (#42930)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
maxproske committed Nov 15, 2022
1 parent 0e8f241 commit efbabd2
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/with-app-layout/README.md
@@ -1,6 +1,6 @@
# With `App` layout example

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

## Deploy your own

Expand Down
6 changes: 6 additions & 0 deletions examples/with-app-layout/package.json
Expand Up @@ -9,5 +9,11 @@
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^18.11.9",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"typescript": "^4.8.4"
}
}
9 changes: 0 additions & 9 deletions examples/with-app-layout/pages/_app.js

This file was deleted.

17 changes: 17 additions & 0 deletions examples/with-app-layout/pages/_app.tsx
@@ -0,0 +1,17 @@
import type { AppProps } from 'next/app'

interface LayoutProps {
children: React.ReactNode
}

const Layout = ({ children }: LayoutProps) => (
<div className="layout">{children}</div>
)

export default function App({ Component, pageProps }: AppProps) {
return (
<Layout>
<Component {...pageProps} />
</Layout>
)
}
File renamed without changes.
20 changes: 20 additions & 0 deletions examples/with-app-layout/tsconfig.json
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

0 comments on commit efbabd2

Please sign in to comment.