Unverified Commit 5044cd60 authored by Max Proske's avatar Max Proske Committed by GitHub

Convert catch-all-routes example to TypeScript (#38188)

Converted Catch All Routes example over to TypeScript to match the Contribution guidelines.

## Documentation / Examples

- [X] Make sure the linting passes by running `pnpm lint`
- [X] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
parent 8f707d4d
......@@ -4,21 +4,17 @@ const Header = () => (
<header>
<ul>
<li>
<Link href="/">
<a>Home</a>
</Link>
<Link href="/">Home</Link>
</li>
<li>
<Link href="/about">
<a>About</a>
</Link>
<Link href="/about">About</Link>
</li>
<li>
<Link
href="/post/[...slug]"
as="/post/2020/first-post/with/catch/all/routes"
>
<a>First Post</a>
First Post
</Link>
</li>
<li>
......@@ -26,7 +22,7 @@ const Header = () => (
href="/post/[...slug]"
as="/post/2020/second-post/with/catch/all/routes"
>
<a>Second Post</a>
Second Post
</Link>
</li>
</ul>
......
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
......@@ -7,7 +7,13 @@
},
"dependencies": {
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^18.0.0",
"@types/react": "^18.0.14",
"@types/react-dom": "^18.0.5",
"typescript": "^4.7.4"
}
}
......@@ -3,7 +3,7 @@ import Header from '../../components/header'
const Comment = () => {
const router = useRouter()
const slug = router.query.slug || []
const slug = (router.query.slug as string[]) || []
return (
<>
......
{
"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"]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment