Skip to content

fix(pre-commit): type-check with tsc -b so build errors are caught#33

Merged
lewisjared merged 2 commits into
mainfrom
fix/precommit-tsc-build-mode
Jul 1, 2026
Merged

fix(pre-commit): type-check with tsc -b so build errors are caught#33
lewisjared merged 2 commits into
mainfrom
fix/precommit-tsc-build-mode

Conversation

@lewisjared

@lewisjared lewisjared commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

The pre-commit TypeScript typecheck hook ran tsc --noEmit, but the root frontend/tsconfig.json is solution-style ("files": [], only project references). Plain tsc --noEmit resolves to that root config and type-checks zero files under src/, so a build-breaking type error passes the gate — locally and in CI — and only surfaces in the real build (tsc -b && vite build).

This switches the hook to tsc -b --noEmit (project-reference build mode, no emit), which descends into the referenced projects (tsconfig.app.json / tsconfig.node.json) exactly as the build does.

-        entry: bash -lc "cd frontend && npx --yes tsc --noEmit"
+        entry: bash -lc "cd frontend && npx --yes tsc -b --noEmit"

Verification

Ran in frontend/ (with deps installed) using a throwaway src/ probe with a string | null | undefinedstring | undefined mismatch:

Command Clean tree Deliberate type error
tsc --noEmit (old) exit 0 exit 0 — false negative, error missed
tsc -b --noEmit (new) exit 0 exit 2error TS2322: Type 'null' is not assignable to type 'string | undefined'

Probe removed afterward; clean tree passes again. TypeScript is 5.8.3, so -b --noEmit is supported (added in 5.6).

Summary by CodeRabbit

  • Bug Fixes

    • Improved the pre-commit TypeScript check so type issues are detected earlier and more reliably before code reaches CI.
  • Chores

    • Updated the changelog with a note about the TypeScript check improvement.

The root frontend/tsconfig.json is solution-style (files: [], only
project references), so the pre-commit hook's plain tsc --noEmit
resolved to it and type-checked zero files under src/. A build-breaking
type error could pass the gate locally and in CI, only surfacing in the
real build (tsc -b && vite build).

Switch the hook to tsc -b --noEmit (project-reference build mode, no
emit), matching what the build actually checks.
@netlify

netlify Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploy Preview for climate-ref canceled.

Name Link
🔨 Latest commit 47da13f
🔍 Latest deploy log https://app.netlify.com/projects/climate-ref/deploys/6a4512d04db7b7000807c879

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The pre-commit typescript-typecheck hook command was changed from tsc --noEmit to tsc -b --noEmit, enabling project build mode. A corresponding changelog entry was added documenting this correction.

Changes

Pre-commit hook update

Layer / File(s) Summary
TypeScript hook build-mode change and changelog
.pre-commit-config.yaml, changelog/33.trivial.md
The typescript-typecheck hook command now uses tsc -b --noEmit instead of tsc --noEmit, and a changelog entry documents this fix.

Metadata

  • No related issues or PRs identified from the provided context.

Suggested labels: none suggested

Suggested reviewers: none suggested

🐰 A tiny flag, a build so bright,
tsc dashes b, checking types just right,
A changelog whisper marks the fix,
Pre-commit hums, no more tricks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: switching the pre-commit TypeScript check to build mode to catch build errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/precommit-tsc-build-mode

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 951382b8-2a57-4d1a-8b20-6c6f8741c72e

📥 Commits

Reviewing files that changed from the base of the PR and between 61fb2dc and 47da13f.

📒 Files selected for processing (2)
  • .pre-commit-config.yaml
  • changelog/33.trivial.md

Comment thread .pre-commit-config.yaml
@lewisjared lewisjared merged commit 13c5f91 into main Jul 1, 2026
9 checks passed
@lewisjared lewisjared deleted the fix/precommit-tsc-build-mode branch July 1, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant