Skip to content

fix(types): make tsc --noEmit clean and add a typecheck script - #5

Merged
aymandakirgh merged 1 commit into
mainfrom
fix/typecheck-clean
Jun 18, 2026
Merged

fix(types): make tsc --noEmit clean and add a typecheck script#5
aymandakirgh merged 1 commit into
mainfrom
fix/typecheck-clean

Conversation

@aymandakirgh

Copy link
Copy Markdown
Owner

Why

npx tsc --noEmit (the project's own config) fails with 3× TS2802 in lib/pdf-report.test.ts:

String.fromCharCode(...bytes.slice(0, 5))
// Type 'Uint8Array<ArrayBuffer>' can only be iterated through when using
// '--downlevelIteration' or '--target' es2015+

Under TypeScript 5.7+ Uint8Array became generic and spreading it trips this. Neither target: es2017 nor downlevelIteration: true clears it — the spread itself is the problem. CI runs lint/test/build but not tsc, so the type error was invisible.

What

  • Read the leading bytes via Array.from(bytes.slice(0, len), (b) => String.fromCharCode(b)).join("") (a small magic() helper used at all three sites) — no typed-array spread, no iteration requirement.
  • Add a "typecheck": "tsc --noEmit" script so the project has a first-class way to catch this (and it can be wired into CI to prevent regression).

Verification

  • npx tsc --noEmitexit 0 (was 3 errors) ✅
  • npm run lint ✅ · npm test228 passed (incl. 6 pdf-report) ✅

Test-only + script addition; no runtime/app code changed.

`npx tsc --noEmit` failed with 3× TS2802 in lib/pdf-report.test.ts:
`String.fromCharCode(...bytes.slice(0, 5))` spreads a Uint8Array, which
under TypeScript 5.7+ (Uint8Array became generic) "can only be iterated
through with --downlevelIteration / target es2015+". Neither tsconfig knob
clears it — the spread itself is the issue. CI runs lint/test/build but not
tsc, so this stayed invisible.

Read the leading bytes via `Array.from(bytes.slice(0, len), (b) =>
String.fromCharCode(b)).join("")` (small `magic()` helper, used at all three
sites) and add a `"typecheck": "tsc --noEmit"` script so the project has a
first-class way to catch this and it can be wired into CI.

Verified: `tsc --noEmit` now exits 0, the 6 pdf-report tests still pass, and
the full unit suite (228) and lint stay green.

Co-authored-by: mattia-mamini-gh <281593356+mattia-mamini-gh@users.noreply.github.com>
@aymandakirgh
aymandakirgh merged commit 3d2ca0f into main Jun 18, 2026
1 check passed
@aymandakirgh
aymandakirgh deleted the fix/typecheck-clean branch June 18, 2026 08:49
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