webarkit / webarkit/jsfeatNext

tsc: extend tsconfig.check.json to tests/** (32 pre-existing type errors)

Open
#171 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
12
Forks
4
Avg merge
16h 24m
Merged PRs (30d)
34

Description

Summary

tsconfig.check.json (added in #170, closing #157) covers src/**/* and bench/**/*, matching #157's proposal exactly except for one thing: #157 also proposed tests/**/*, which was left out because widening to it surfaces 32 pre-existing type errors that predate #170 entirely — they were already there, just never checked, for the same reason #157 existed: tsconfig.json never looked at anything outside src/.

This issue tracks fixing those 32 and then widening tsconfig.check.json's include to add tests/**/* (with tests/vendor/** excluded, since that's the third-party oracle, never ours to fix).

Reproduce

cat > /tmp/tsconfig.tests-check.json <<'JSON'
{
  "extends": "./tsconfig.json",
  "include": ["src/**/*", "bench/**/*", "tests/**/*"],
  "exclude": ["tests/vendor/**"]
}
JSON
npx tsc --noEmit -p /tmp/tsconfig.tests-check.json

The 32 errors, by file

file count
tests/parity/linalg.test.ts 13
tests/parity/matmath.test.ts 10
tests/parity/motion_estimator.test.ts 3
tests/reference/known-values.test.ts 2
tests/reference/imgproc.test.ts 2
tests/reference/reference-impl.ts 1
tests/properties/edge-cases.test.ts 1

Two repeating patterns, not 32 separate bugs

23 of 32 are matrix_t passed where a typed-array-shaped structural type is expected ({ data: Float32Array<ArrayBufferLike> }), in linalg.test.ts and matmath.test.ts. matrix_t.data is typed as the TypedArray union (Uint8Array | Int32Array | Float32Array | Float64Array), so TS can't narrow it to the specific typed array a helper signature demands — even though every call site is correct at runtime. Likely fixable by typing the affected test helpers against matrix_t/IMatrix_T directly instead of an ad hoc structural type, rather than touching src/.

5 of 32 are plain { x: number; y: number } object literals passed where point_t[] is expected, in motion_estimator.test.ts and known-values.test.ts. Same shape as the type error #157 itself found and the fix in #160's motion_estimator.bench.ts (point_t's constructor leaves fields unset by design, so a literal doesn't satisfy the interface) — these test files predate that fix and use the shortcut it warned against.

4 remaining are one-offs (Int32Array | Float32Array union narrowing in reference-impl.ts, number[] mismatches in imgproc.test.ts / edge-cases.test.ts) — worth a look individually, not part of either pattern above.

Why this matters

None of these are found by npm test (tests/** runs fine at runtime — vitest doesn't type-check) or by tsc -p tsconfig.json (scope is src/ only). They've been invisible for as long as the test suite has existed. #157 exists specifically because that invisibility let a real bug survive several PRs in bench/; the same gap exists in tests/ right now, just not yet triggered by anything as concrete.

Acceptance criteria

  • All 32 errors fixed — test files only, no src/ behavior change (these are type-level fixes; the tests already pass at runtime).
  • tsconfig.check.json's include widened to ["src/**/*", "bench/**/*", "tests/**/*"] with tests/vendor/** excluded.
  • npm run typecheck (used by CI.yml) stays green with the wider scope.
  • npm test still green — confirms no behavior changed, only types.

Related

  • Follow-up from: #170 (closed #157 for bench/, deferred tests/ here)
  • Same underlying pattern as: #157
  • The point_t construction shortcut this echoes: #160 (motion_estimator.bench.ts)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided npx tsc --noEmit command with the temporary config and inspect the 32 errors in the seven listed test files. Review the matrix_t/IMatrix_T and point_t patterns, then check the one-off errors individually. Done means all errors are fixed in tests, tsconfig.check.json includes tests//* while excluding tests/vendor/, and npm run typecheck plus npm test remain green.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.