Skip to content

Commit

Permalink
typescript example
Browse files Browse the repository at this point in the history
  • Loading branch information
ericclemmons committed Mar 10, 2019
1 parent efb8ebb commit aa55dc4
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 30 deletions.
19 changes: 19 additions & 0 deletions examples/typescript/package.json
@@ -0,0 +1,19 @@
{
"private": true,
"name": "typescript-example",
"version": "0.0.0",
"devDependencies": {
"ts-node": "^8.0.3",
"typescript": "^3.3.3333"
},
"scripts": {
"dev": "polydev --require ts-node/register",
"prestart": "tsc",
"start": "cd dist && NODE_ENV=production polydev"
},
"dependencies": {
"@types/express": "^4.16.1",
"react": "^16.8.4",
"react-dom": "^16.8.4"
}
}
39 changes: 39 additions & 0 deletions examples/typescript/routes/index.tsx
@@ -0,0 +1,39 @@
import { Request, Response } from "express"
import * as React from "react"
import { renderToStaticMarkup } from "react-dom/server"

let hits = 0

export default (req: Request, res: Response) => {
hits++

res.send(
renderToStaticMarkup(
<>
<link
href="https://fonts.googleapis.com/css?family=Quicksand:300,500"
rel="stylesheet"
/>
<link href="/_polydev/styles.css" rel="stylesheet" />

<div id="splash" />

<section>
<main>
<h1>
👋 Howdy from <kbd>TypeScript</kbd>
</h1>

<p>
<kbd>{hits}</kbd> {hits ? "hits" : "hit"}
</p>
</main>

<footer>
<a href="/">&laquo; Back</a>
</footer>
</section>
</>
)
)
}
8 changes: 8 additions & 0 deletions examples/typescript/tsconfig.json
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"allowJs": true,
"jsx": "react",
"outDir": "dist",
"rootDir": "."
}
}
30 changes: 0 additions & 30 deletions routes/typescript/index.tsx

This file was deleted.

0 comments on commit aa55dc4

Please sign in to comment.