fix(types): make tsc --noEmit clean and add a typecheck script - #5
Merged
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
npx tsc --noEmit(the project's own config) fails with 3× TS2802 inlib/pdf-report.test.ts:Under TypeScript 5.7+
Uint8Arraybecame generic and spreading it trips this. Neithertarget: es2017nordownlevelIteration: trueclears it — the spread itself is the problem. CI runs lint/test/build but nottsc, so the type error was invisible.What
Array.from(bytes.slice(0, len), (b) => String.fromCharCode(b)).join("")(a smallmagic()helper used at all three sites) — no typed-array spread, no iteration requirement."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 --noEmit→ exit 0 (was 3 errors) ✅npm run lint✅ ·npm test→ 228 passed (incl. 6 pdf-report) ✅Test-only + script addition; no runtime/app code changed.