From 004e2fbcb28f75875147a34f3b5863d75bc4f9de Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Mon, 24 Feb 2020 16:16:49 +0100 Subject: [PATCH] TypeScript: Tighten configs to improve type validation TypeScript considers null and undefined as fine for all variable by default. This patch enables `strictNullChecks`, which should cause errors to be thrown as soon as a variable is null or undefined without having it explicitly decleared for itself.[1] [1]: https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html#strict-null--undefined-checks Signed-off-by: Sheogorath --- lib/web/note/util.ts | 2 +- tsconfig.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/web/note/util.ts b/lib/web/note/util.ts index 09cd60e94..3dcb42941 100644 --- a/lib/web/note/util.ts +++ b/lib/web/note/util.ts @@ -47,7 +47,7 @@ export module NoteUtils { } } - export function newNote(req: any, res: Response, body: string) { + export function newNote(req: any, res: Response, body: string | null) { let owner = null; const noteId = req.params.noteId ? req.params.noteId : null; if (req.isAuthenticated()) { diff --git a/tsconfig.json b/tsconfig.json index e69515925..ef2dd7ee8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "outDir": "./built", "allowJs": true, + "strictNullChecks": true, "target": "es5", "module": "commonjs", "esModuleInterop": true