Skip to content

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

Description

@kalwalt

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions