Skip to content

Commit 38938bd

Browse files
committed
react-typescript starter fixes
1 parent cdd8328 commit 38938bd

File tree

6 files changed

+52
-5
lines changed

6 files changed

+52
-5
lines changed

examples/react-vanilla-ts-src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "example-react-vanilla",
2+
"name": "example-react-vanilla-ts-src",
33
"type": "module",
44
"scripts": {
55
"dev": "tsx src/server.ts --dev",

pnpm-lock.yaml

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

starters/react-typescript/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dev": "tsx server.ts --dev",
66
"start": "NODE_ENV=production node dist/server.js",
77
"build": "pnpm build:client && pnpm build:server",
8-
"build:server": "tsdown server.ts",
8+
"build:server": "tsc && tsdown server.ts",
99
"build:client": "NODE_ENV=production vite build"
1010
},
1111
"dependencies": {
@@ -24,12 +24,16 @@
2424
},
2525
"devDependencies": {
2626
"@tailwindcss/postcss": "^4.1.1",
27+
"@types/node": "^22.13.17",
28+
"@types/react": "^19.1.2",
29+
"@types/react-dom": "^19.1.2",
2730
"@vitejs/plugin-react": "^4.3.4",
2831
"oxlint": "^0.16.6",
2932
"postcss": "^8.5.3",
3033
"postcss-preset-env": "^10.1.5",
3134
"tailwindcss": "^4.1.1",
3235
"tsdown": "^0.9.1",
36+
"typescript": "^5.8.3",
3337
"vite": "^6.2.4"
3438
}
3539
}

starters/react-typescript/server.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ const server = Fastify({
1010
}
1111
})
1212

13+
// @ts-ignore
1314
await server.register(FastifyFormBody)
15+
// @ts-ignore
1416
await server.register(FastifyVite, {
15-
root: import.meta.dirname,
17+
// TODO handle via CLI path argument with proper resolve
18+
root: process.cwd(),
1619
renderer: '@fastify/react',
1720
})
1821

22+
// @ts-ignore
1923
await server.vite.ready()
2024

2125
server.decorate('db', {
@@ -27,11 +31,13 @@ server.decorate('db', {
2731
})
2832

2933
server.put('/api/todo/items', (req, reply) => {
34+
// @ts-ignore
3035
server.db.todoList.push(req.body)
3136
reply.send({ ok: true })
3237
})
3338

3439
server.delete('/api/todo/items', (req, reply) => {
40+
// @ts-ignore
3541
server.db.todoList.splice(req.body, 1)
3642
reply.send({ ok: true })
3743
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"lib": ["es2022", "DOM"],
5+
"module": "esnext",
6+
"moduleResolution": "bundler",
7+
"resolveJsonModule": true,
8+
"types": ["node"],
9+
"strict": true,
10+
"noUnusedLocals": true,
11+
"declaration": true,
12+
"isolatedDeclarations": false,
13+
"esModuleInterop": true,
14+
"verbatimModuleSyntax": true,
15+
"skipLibCheck": true,
16+
"outDir": "dist",
17+
"jsx": "react-jsx",
18+
},
19+
"include": [
20+
"./server.ts",
21+
],
22+
"exclude": ["**/*.test.ts"]
23+
}

starters/react-typescript/vite.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { join, dirname } from 'path'
1+
import { join, resolve } from 'path'
22
import { fileURLToPath } from 'url'
33

44
import viteReact from '@vitejs/plugin-react'
@@ -12,4 +12,7 @@ export default {
1212
ts: true
1313
}),
1414
],
15+
build: {
16+
outDir: resolve(import.meta.dirname, 'dist')
17+
},
1518
}

0 commit comments

Comments
 (0)