Update custom-server-typescript example (#6627)

* Typecheck server vs. client code independently, ensuring that each respects its own tsconfig.
* Use nextjs default distDir in tsconfig
* Update packages
* Fix type error in server.listen callback
This commit is contained in:
Brent Ertz 2019-03-16 09:42:22 -06:00 committed by Tim Neutkens
parent 4559b05a34
commit 4c4459f931
4 changed files with 21 additions and 19 deletions

View file

@ -1,21 +1,21 @@
{ {
"scripts": { "scripts": {
"dev": "nodemon", "dev": "nodemon",
"build": "next build && tsc --project tsconfig.server.json", "build": "next build && tsc && tsc --project tsconfig.server.json",
"start": "cross-env NODE_ENV=production node dist/index.js" "start": "cross-env NODE_ENV=production node .next/server"
}, },
"dependencies": { "dependencies": {
"@zeit/next-typescript": "^1.1.0", "@zeit/next-typescript": "^1.1.1",
"next": "^7.0.0", "next": "^8.0.3",
"react": "^16.7.0", "react": "^16.8.4",
"react-dom": "^16.7.0" "react-dom": "^16.8.4"
}, },
"devDependencies": { "devDependencies": {
"@types/next": "^7.0.0", "@types/next": "^7.0.9",
"@types/react": "^16.6.0", "@types/react": "^16.8.7",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"nodemon": "^1.18.8", "nodemon": "^1.18.10",
"ts-node": "^7.0.1", "ts-node": "^7.0.1",
"typescript": "^3.2.0" "typescript": "^3.3.3333"
} }
} }

View file

@ -21,8 +21,7 @@ app.prepare()
handle(req, res, parsedUrl) handle(req, res, parsedUrl)
} }
}) })
.listen(port, (err) => { .listen(port, () => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`) console.log(`> Ready on http://localhost:${port}`)
}) })
}) })

View file

@ -1,6 +1,7 @@
{ {
"compileOnSave": false, "compileOnSave": false,
"compilerOptions": { "compilerOptions": {
"noEmit": true,
"target": "esnext", "target": "esnext",
"module": "esnext", "module": "esnext",
"jsx": "preserve", "jsx": "preserve",
@ -21,6 +22,8 @@
"dom", "dom",
"es2015", "es2015",
"es2016" "es2016"
] ],
} "outDir": ".next"
},
"exclude": [".next", "server/**/*.*"]
} }

View file

@ -1,12 +1,12 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"noEmit": false,
"module": "commonjs", "module": "commonjs",
"outDir": "dist",
"target": "es2017", "target": "es2017",
"lib": [ "lib": ["es2017"],
"es2017" "outDir": ".next/server"
]
}, },
"include": ["server/**/*.ts"] "include": ["server/**/*.ts"],
"exclude": [".next"]
} }