Skip to content

Commit 5406af0

Browse files
fix: improve the typescript sample (#1015)
1 parent 801f853 commit 5406af0

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

appengine/typescript/index.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,12 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
/* tslint:disable:no-console */
15+
const PORT = Number(process.env.PORT) || 8080;
16+
import * as express from "express";
1617

17-
declare var process: {
18-
env: {
19-
PORT: string,
20-
},
21-
};
18+
const app = express();
2219

23-
const PORT: number = Number(process.env.PORT) || 8080;
24-
import express = require("express");
25-
26-
const app: any = express();
27-
28-
app.get("/", (req: any, res: any) => {
20+
app.get("/", (req, res) => {
2921
res.send("🎉 Hello TypeScript! 🎉");
3022
});
3123

appengine/typescript/package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
"node": ">=8.0.0"
1010
},
1111
"scripts": {
12-
"test": "npm run gcp-build && npm run lint && repo-tools test app -- index.js",
13-
"lint": "tslint index.ts",
12+
"prepare": "npm run gcp-build",
13+
"pretest": "npm run gcp-build",
14+
"test": "repo-tools test app -- index.js",
15+
"posttest": "npm run lint",
16+
"lint": "tslint -p .",
1417
"start": "node ./index.js",
15-
"gcp-build": "tsc index.ts",
18+
"gcp-build": "tsc -p .",
1619
"deploy": "gcloud app deploy"
1720
},
1821
"dependencies": {
@@ -21,6 +24,7 @@
2124
},
2225
"devDependencies": {
2326
"@google-cloud/nodejs-repo-tools": "^2.3.3",
27+
"@types/express": "^4.16.0",
2428
"tslint": "^5.11.0"
2529
}
2630
}

appengine/typescript/tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2016",
4+
"module": "commonjs"
5+
},
6+
"include": [
7+
"*.ts"
8+
]
9+
}

appengine/typescript/tslint.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "tslint:recommended"
2+
"extends": "tslint:recommended",
3+
"rules": {
4+
"no-console": false
5+
}
36
}

0 commit comments

Comments
 (0)