From 82bdd4328573a38e43ccb75998afc9560ac6c250 Mon Sep 17 00:00:00 2001 From: Emmanuel Letallieur Date: Tue, 4 Sep 2018 17:35:34 +0200 Subject: [PATCH] Fix custom-server-typescript not typechecking (#3954) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi In the current version of the example __custom-server-typescript__, types are never checked. For instance, change the following line : ``` const dev = process.env.NODE_ENV !== 'production' ``` by : ``` const dev: number = process.env.NODE_ENV !== 'production' ``` then run `npm run dev`. The application launches perfectly, no error is thrown. In dev environnement, it is preferable to check types all the time, to get immediate feedback. This PR activates type checking. Only when using nodemon, so no impact on production. Now the above code will (rightfully) refuse to compile : ``` TSError: тип Unable to compile TypeScript server/index.ts (6,7): Type 'boolean' is not assignable to type 'number' ``` --- examples/custom-server-typescript/nodemon.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/custom-server-typescript/nodemon.json b/examples/custom-server-typescript/nodemon.json index 24f3bee0..2df1d50d 100644 --- a/examples/custom-server-typescript/nodemon.json +++ b/examples/custom-server-typescript/nodemon.json @@ -1,6 +1,6 @@ { "watch": ["server/**/*.ts"], "execMap": { - "ts": "ts-node --compilerOptions '{\"module\":\"commonjs\"}'" + "ts": "ts-node --typeCheck --compilerOptions '{\"module\":\"commonjs\"}'" } }