Skip to content

Commit

Permalink
Convert hello-world example to TypeScript (#37706)
Browse files Browse the repository at this point in the history
TypeScript is being leveraged for new examples going forward, so I'm converting this example over. πŸ˜‚

## 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)
  • Loading branch information
maxproske committed Jun 15, 2022
1 parent 0f873c7 commit 007d186
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/hello-world/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hello World example

This example shows the most basic idea behind Next. We have 2 pages: `pages/index.js` and `pages/about.js`. The former responds to `/` requests and the latter to `/about`. Using `next/link` you can add hyperlinks between them with universal routing capabilities. The `day` directory shows that you can have subdirectories.
This example shows the most basic idea behind Next. We have 2 pages: `pages/index.tsx` and `pages/about.tsx`. The former responds to `/` requests and the latter to `/about`. Using `next/link` you can add hyperlinks between them with universal routing capabilities. The `day` directory shows that you can have subdirectories.

## Deploy your own

Expand Down
5 changes: 5 additions & 0 deletions examples/hello-world/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <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.
10 changes: 8 additions & 2 deletions examples/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "^17.0.43",
"@types/react": "^18.0.12",
"@types/react-dom": "^18.0.5",
"typescript": "^4.7.3"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions examples/hello-world/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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 007d186

Please sign in to comment.