Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The current TypeScript "with-typescript" looks like it was put there … #6011

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions examples/with-typescript/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Props = {
title?: string
}

const Layout: React.SFC<Props> = ({ children, title = 'This is the default title' }) => (
const Layout: React.FunctionComponent<Props> = ({ children, title = 'This is the default title' }) => (
<div>
<Head>
<title>{title}</title>
Expand All @@ -15,13 +15,15 @@ const Layout: React.SFC<Props> = ({ children, title = 'This is the default title
</Head>
<header>
<nav>
<Link href='/'><a>Home</a></Link> |{' '}
<Link href='/about'><a>About</a></Link>
<Link href='/'><a>Home</a></Link> | {' '}
<Link href='/list'><a>List</a></Link> | {' '}
<Link href='/about'><a>About</a></Link> | {' '}
</nav>
</header>
{children}
<footer>
I'm here to stay
<hr/>
<span>I'm here to stay (Footer)</span>
</footer>
</div>
)
Expand Down
23 changes: 23 additions & 0 deletions examples/with-typescript/components/List.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from "react"
import ListItem from './ListItem'

export interface DataObject {
id: number,
name: string
}

const List : React.FunctionComponent = () => {
const dataArray : DataObject[] =
[{id: 101, name: 'larry'}, {id: 102, name: 'sam'}, {id: 103, name: 'jill'}]
return (
<ul>
{dataArray.map(item => (
<li key={item.id}>
<ListItem data={item}/>
</li>
))}
</ul>
)
}

export default List;
12 changes: 12 additions & 0 deletions examples/with-typescript/components/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from 'react'
import {DataObject} from "./List";

export interface Props {
data: DataObject
}

const ListItem: React.FunctionComponent<Props> = ({ data }) => (
<React.Fragment>{data.id}:{data.name}</React.Fragment>
);

export default ListItem;
8 changes: 5 additions & 3 deletions examples/with-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
},
"dependencies": {
"@zeit/next-typescript": "^1.1.1",
"next": "latest",
"lint": "^1.1.2",
"next": "^7.0.2",
"react": "^16.7.0",
"react-dom": "^16.7.0"
},
"devDependencies": {
"@types/next": "^7.0.1",
"@types/next": "^7.0.2",
"@types/react": "^16.4.16",
"@types/react-dom": "16.0.8",
"typescript": "3.1.1"
"eslint": "^5.12.0",
"typescript": "3.2.1"
},
"license": "ISC"
}
7 changes: 5 additions & 2 deletions examples/with-typescript/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import * as React from "react"
import Link from 'next/link'
import Layout from '../components/Layout';

export default () => (
const about : React.FunctionComponent = () => (
<Layout title="About | Next.js + TypeScript Example">
<p>This is the about page</p>
<p><Link href='/'><a>Go home</a></Link></p>
</Layout>
)
)

export default about;
19 changes: 12 additions & 7 deletions examples/with-typescript/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import * as React from "react"
import Link from 'next/link'
import Layout from '../components/Layout';
import Layout from '../components/Layout'

export default () => (
<Layout title="Home | Next.js + TypeScript Example">
<h1>Hello Next.js 👋</h1>
<p><Link href='/about'><a>About</a></Link></p>
</Layout>
)
const index : React.FunctionComponent = () => {
return (
<Layout title="Home | Next.js + TypeScript Example">
<h1>Hello Next.js 👋</h1>
<p><Link href='/about'><a>About</a></Link></p>
</Layout>
)
}

export default index;
11 changes: 11 additions & 0 deletions examples/with-typescript/pages/list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as React from "react"
import Layout from '../components/Layout'
import List from '../components/List'

const list : React.FunctionComponent = () => (
<Layout title="About | Next.js + TypeScript Example">
<List/>
</Layout>
)

export default list;