From 163bd96ad5d3b3c4b690d9166973cc0e1fc7aa22 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Thu, 4 Nov 2021 10:06:53 +0000 Subject: [PATCH] build: strictly typecheck the codebase This change enables TypeScript's strict mode, which allows various bugs to be revealed and shows areas that remain untyped. As there are many things to fix, I've added an optional step to the CI workflow. Refs #398, #422 --- .github/workflows/develop.yml | 4 ++++ Makefile | 6 +++++- package.json | 1 + tsconfig.json | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 6916dbac..bfbc7899 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -26,6 +26,10 @@ jobs: env: TARGET: 'dev' + - name: 'Typecheck' + run: make typecheck + continue-on-error: true + - name: 'Lint' run: make lint diff --git a/Makefile b/Makefile index 0357bf4c..d46f422d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .DEFAULT_GOAL: help -.PHONY: help build run dev prod start logs stop wait-healthy lint format test integration-test smoke-test +.PHONY: help build run dev prod start logs stop wait-healthy typecheck lint format test integration-test smoke-test ifeq (${TARGET},) TARGET := dev @@ -46,6 +46,10 @@ endif wait-healthy: ## Wait for the app to be healthy @.scripts/wait-healthy.sh prereview +typecheck: export TARGET = dev +typecheck: build ## Run the typechecker + @${DOCKER_COMPOSE} run --rm --no-deps --entrypoint "npm run" prereview typecheck + lint: export TARGET = dev lint: build ## Run the linter @${DOCKER_COMPOSE} run --rm --no-deps --entrypoint "npm run" prereview lint diff --git a/package.json b/package.json index 840cb9ec..45898267 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "format": "prettier --ignore-unknown --check '**'", "lint": "eslint --ext .js,.jsx,.ts,.tsx .", "test": "jest", + "typecheck": "tsc --noEmit --project tsconfig.dev.json", "build": "rimraf dist && npm run build:scripts && npm run build:backend && npm run build:hooks && npm run build:frontend", "build:dev": "rimraf dist && npm run build:scripts && npm run build:backend:dev && npm run build:hooks && npm run build:frontend:dev", "build:backend": "parcel build --target=backend --no-optimize src/backend/index.ts && npm run build:templates", diff --git a/tsconfig.json b/tsconfig.json index 17c7cce0..a27474d4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "declaration": true, "isolatedModules": true, - "noImplicitAny": false, + "strict": true, "removeComments": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true,