From f2b22689207b7a3d630c2652e411a6cb475f1917 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:05:07 -0800 Subject: [PATCH 1/2] Check types in CI Previously, the only enforcement of TypeScript was through ESLint rules from @typescript-eslint. Note that a build is necessary before checking to generate the static-site/next-env.d.ts file which provides types from Next.js. --- .github/workflows/ci.yml | 10 ++++++++++ package.json | 2 ++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1eeda2a95..a8c82e1a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,16 @@ jobs: - run: npm run lint:static-site - run: node ./scripts/check-resource-index-match.js + type-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: 'package.json' + - run: npm ci + - run: npm run type-check:ci + # Build into Heroku slug so we can deploy the same build that we test. build: runs-on: ubuntu-latest diff --git a/package.json b/package.json index 6de3d7c74..ee7baefd4 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,8 @@ "lint": "npm run lint:server", "lint:server": "DEBUG=eslint:cli-engine npx eslint --max-warnings=0 --ext .js,.jsx .", "lint:static-site": "cd static-site && DEBUG=eslint:cli-engine npx eslint --max-warnings=0 --ext .js,.jsx,.ts,.tsx .", + "type-check": "cd static-site && tsc", + "type-check:ci": "npm run build && cd static-site && tsc", "server": "node server.js", "groups": "node server.js --app ./src/groupsApp.js", "start": "npm run server", From 8ea90e59591e06fdf53dfdcbe6f7568b81423792 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:13:15 -0800 Subject: [PATCH 2/2] Remove CSS/image static import types These are provided by Next.js in static-site/next-env.d.ts, which is generated during build. --- static-site/types.d.ts | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/static-site/types.d.ts b/static-site/types.d.ts index 38acd62a2..3041bb4ee 100644 --- a/static-site/types.d.ts +++ b/static-site/types.d.ts @@ -1,23 +1,3 @@ -declare module "*.css" { - const value: unknown; - export default value; -} - -declare module "*.jpg" { - const value: { src: string }; - export default value; -} - -declare module "*.png" { - const value: { src: string }; - export default value; -} - -declare module "*.svg" { - const value: { src: string }; - export default value; -} - declare module "*.yaml" { // Actual type should be set upon import via type assertion. const contents: unknown;