diff --git a/examples/with-typescript/interfaces/index.tsx b/examples/with-typescript/interfaces/index.tsx
index c5e83bb8f0a271aa6483608499017b745854a293..c6f451c1f67d2127f286118d4f09d9a33095d308 100644
--- a/examples/with-typescript/interfaces/index.tsx
+++ b/examples/with-typescript/interfaces/index.tsx
@@ -1,4 +1,10 @@
+// You can include shared interfaces in a separate file and then
+// use them in any component by importing them. For example, to
+// import the interface below do:
+//
+// import IDataObject from 'path/to/interfaces';
+
export default interface IDataObject {
- id: number,
+ id: number
name: string
}
diff --git a/examples/with-typescript/package.json b/examples/with-typescript/package.json
index c449f208e87cab52475e90c0a7a10a4524134e39..c535a6329e146895ddfe540fadc76eac7e571006 100644
--- a/examples/with-typescript/package.json
+++ b/examples/with-typescript/package.json
@@ -9,7 +9,6 @@
},
"dependencies": {
"@zeit/next-typescript": "^1.1.1",
- "lint": "^1.1.2",
"next": "^7.0.2",
"react": "^16.7.0",
"react-dom": "^16.7.0"
@@ -17,9 +16,8 @@
"devDependencies": {
"@types/next": "^7.0.6",
"@types/react": "^16.4.16",
- "@types/react-dom": "16.0.8",
- "eslint": "^5.12.0",
- "typescript": "3.2.1"
+ "@types/react-dom": "16.0.11",
+ "typescript": "3.2.4"
},
"license": "ISC"
}
diff --git a/examples/with-typescript/pages/about.tsx b/examples/with-typescript/pages/about.tsx
index 86b1aa24d8040507e3df2395bedff81ade912a51..0e01004bf915138a1b0583c5a3960b47b1783604 100644
--- a/examples/with-typescript/pages/about.tsx
+++ b/examples/with-typescript/pages/about.tsx
@@ -1,12 +1,12 @@
-import * as React from "react"
+import * as React from 'react'
import Link from 'next/link'
-import Layout from '../components/Layout';
+import Layout from '../components/Layout'
-const about : React.FunctionComponent = () => (
+const AboutPage: React.FunctionComponent = () => (
This is the about page
Go home
)
-export default about;
\ No newline at end of file
+export default AboutPage;
diff --git a/examples/with-typescript/pages/index.tsx b/examples/with-typescript/pages/index.tsx
index 774cd76806903669ae60b4e0fd5304ae1bb0be1a..fe36c9c00a498aa272110bd934a55cf9ff5e3e4c 100644
--- a/examples/with-typescript/pages/index.tsx
+++ b/examples/with-typescript/pages/index.tsx
@@ -1,8 +1,8 @@
-import * as React from "react"
+import * as React from 'react'
import Link from 'next/link'
import Layout from '../components/Layout'
-const index: React.FunctionComponent = () => {
+const IndexPage: React.FunctionComponent = () => {
return (
Hello Next.js 👋
@@ -11,4 +11,4 @@ const index: React.FunctionComponent = () => {
)
}
-export default index;
+export default IndexPage;
diff --git a/examples/with-typescript/pages/list-class.tsx b/examples/with-typescript/pages/list-class.tsx
index 202bca3c5939704182eaf9e701a92768d1e23c0e..3e290146779a3fea033b7db74c4ae6bc716689ce 100644
--- a/examples/with-typescript/pages/list-class.tsx
+++ b/examples/with-typescript/pages/list-class.tsx
@@ -11,15 +11,22 @@ type Props = {
class ListClass extends React.Component {
static async getInitialProps({ pathname }: NextContext) {
- const dataArray: IDataObject[] =
- [{ id: 101, name: 'larry' }, { id: 102, name: 'sam' }, { id: 103, name: 'jill' }, { id: 104, name: pathname }]
+ // Example for including initial props in a Next.js page.
+ // Don't forget to include the respective types for any
+ // props passed into the component
+ const dataArray: IDataObject[] = [
+ { id: 101, name: 'larry' },
+ { id: 102, name: 'sam' },
+ { id: 103, name: 'jill' },
+ { id: 104, name: pathname },
+ ]
return { items: dataArray }
}
render() {
return (
-
+
)
diff --git a/examples/with-typescript/pages/list-fc.tsx b/examples/with-typescript/pages/list-fc.tsx
index dcb9f92c011753b4a13d21fc7d7ab7e004d2fc93..3fd6fe652c4fe9ccdaab9554b5e8526a57a67cbf 100644
--- a/examples/with-typescript/pages/list-fc.tsx
+++ b/examples/with-typescript/pages/list-fc.tsx
@@ -7,17 +7,24 @@ type Props = {
items: IDataObject[],
}
-const list: NextFunctionComponent = ({ items }) => (
-
+const ListFunction: NextFunctionComponent = ({ items }) => (
+
)
-list.getInitialProps = async ({ pathname }: NextContext) => {
- const dataArray: IDataObject[] =
- [{ id: 101, name: 'larry' }, { id: 102, name: 'sam' }, { id: 103, name: 'jill' }, { id: 104, name: pathname }]
+ListFunction.getInitialProps = async ({ pathname }: NextContext) => {
+ // Example for including initial props in a Next.js function compnent page.
+ // Don't forget to include the respective types for any props passed into
+ // the component.
+ const dataArray: IDataObject[] = [
+ { id: 101, name: 'larry' },
+ { id: 102, name: 'sam' },
+ { id: 103, name: 'jill' },
+ { id: 104, name: pathname },
+ ]
return { items: dataArray }
}
-export default list
+export default ListFunction