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 <sheogorath@shivering-isles.com>
This commit is contained in:
Sheogorath 2020-02-24 16:16:49 +01:00
parent d8c424297b
commit 004e2fbcb2
No known key found for this signature in database
GPG key ID: C9B1C80737B9CE18
2 changed files with 2 additions and 1 deletions

View file

@ -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; let owner = null;
const noteId = req.params.noteId ? req.params.noteId : null; const noteId = req.params.noteId ? req.params.noteId : null;
if (req.isAuthenticated()) { if (req.isAuthenticated()) {

View file

@ -2,6 +2,7 @@
"compilerOptions": { "compilerOptions": {
"outDir": "./built", "outDir": "./built",
"allowJs": true, "allowJs": true,
"strictNullChecks": true,
"target": "es5", "target": "es5",
"module": "commonjs", "module": "commonjs",
"esModuleInterop": true "esModuleInterop": true